Skip to content

Commit 02e57ba

Browse files
committed
Quick fixes after use testing
1 parent 872ba65 commit 02e57ba

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

nix_tree/composer.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""contains the composer which builds the file"""
22

33
import re
4+
import os
45
from dataclasses import dataclass
56

67
from nix_tree.errors import NoValidHeadersNode, ErrorComposingFileFromTree
@@ -31,10 +32,14 @@ def __init__(self, tree: DecomposerTree, file_location: str, write_over: bool, c
3132
"""
3233

3334
self.__tree = tree
34-
if write_over:
35-
self.__file_location = file_location
35+
if os.access(file_location, os.W_OK):
36+
if write_over:
37+
self.__file_location = file_location
38+
else:
39+
self.__file_location = file_location + ".new"
3640
else:
37-
self.__file_location = file_location + ".new"
41+
print("\033[93m No permission to write to the file/directory containing the original file, writing to current directory instead \033[91m")
42+
self.__file_location = os.getcwd() + "/" + file_location.split("/")[-1:][0]
3843
self.__composer_iterator = ComposerIterator()
3944
self.__write_to_file(comments)
4045

nix_tree/ui.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def __extract_data_from_action(self, action: str) -> tuple[str, str, str]:
207207
variable = "[" + match.group(3) + "]"
208208
else:
209209
raise ErrorComposingFileFromTree(message="Was unable to parse actions to apply to tree")
210-
full_path = path + variable
210+
full_path = path + "=" + variable
211211
elif "'" in action: # Any of the string types
212212
if match := re.search(r"(Added|Delete|Change) (.*)''(.*)''", action):
213213
path = match.group(2)[:-1]
@@ -217,7 +217,7 @@ def __extract_data_from_action(self, action: str) -> tuple[str, str, str]:
217217
variable = "'" + match.group(3) + "'"
218218
else:
219219
raise ErrorComposingFileFromTree(message="Was unable to parse actions to apply to tree")
220-
full_path = path + variable
220+
full_path = path + "=" + variable
221221
else: # bool and unique
222222
full_path = action.split(" ")[1]
223223
path = full_path.split("=")[0]

0 commit comments

Comments
 (0)