Skip to content

Commit

Permalink
Normalize all paths
Browse files Browse the repository at this point in the history
  • Loading branch information
wsarce committed Nov 24, 2021
1 parent 28afd57 commit 9d5c9dc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions experiment_select_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ def populate_experiments(self):
def load_experiments(self):
self.top_dir = None
while not self.top_dir:
self.top_dir = filedialog.askdirectory(title='Select root directory to save files')
self.top_dir = path.normpath(filedialog.askdirectory(title='Select root directory to save files'))
print(self.top_dir)
if not self.top_dir:
if not messagebox.askokcancel("Exit", "Press cancel to close program"):
sys.exit()
if path.isdir(self.top_dir):
_, dirs, _ = next(walk(self.top_dir))
for dir in dirs:
self.experiment_dirs.append(path.join(self.top_dir, dir))
self.experiment_dirs.append(path.normpath(path.join(self.top_dir, dir)))
else:
os.mkdir(path.join(self.top_dir, 'experiments'))

Expand Down Expand Up @@ -114,7 +114,7 @@ def quit_app(self):

def create_experiment(self, experiment_name):
os.mkdir(path.join(self.top_dir, experiment_name))
self.experiment_dir = path.join(self.top_dir, experiment_name)
self.experiment_dir = path.normpath(path.join(self.top_dir, experiment_name))

def fixed_map(self, option):
# https://stackoverflow.com/a/62011081
Expand Down
6 changes: 3 additions & 3 deletions keystroke_file_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def load_keystrokes(self, directory):
if pathlib.Path(file).suffix == ".json":
if not valid_dir:
valid_dir = True
self.keystroke_files.append(path.join(directory, file))
self.keystroke_files.append(path.normpath(path.join(directory, file)))
else:
if not path.isdir(self.experiment_dir):
os.mkdir(self.experiment_dir)
Expand All @@ -110,7 +110,7 @@ def create_keystroke(self, name):
"Duration": []
}
json.dump(x, f)
self.keystroke_file = path.join(self.keystroke_directory, name + '.json')
self.keystroke_file = path.normpath(path.join(self.keystroke_directory, name + '.json'))

def new_keystroke_quit(self, name):
if name and name != "":
Expand Down Expand Up @@ -266,7 +266,7 @@ def import_ksf(self):
"Add sheet called 'Conditions' for this feature!")
name = pathlib.Path(filename).stem
# TODO: Seth encountered a File Not Found error here
with open(path.join(self.caller.keystroke_directory, name + '.json'), 'w') as f:
with open(path.normpath(path.join(self.caller.keystroke_directory, name + '.json')), 'w') as f:
x = {
"Name": name,
"Frequency": freq_keys,
Expand Down
4 changes: 2 additions & 2 deletions patient_select_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def load_patients(self, directory):
if pathlib.Path(file).suffix == ".json":
if not valid_dir:
valid_dir = True
self.patient_files.append(path.join(directory, file))
self.patient_files.append(path.normpath(path.join(directory, file)))
else:
os.mkdir(self.patients_dir)

Expand Down Expand Up @@ -116,7 +116,7 @@ def create_patient(self, patient_name):
"MRN": ""
}
json.dump(x, f)
self.patient_file = path.join(self.patients_dir, patient_name + '.json')
self.patient_file = path.normpath(path.join(self.patients_dir, patient_name + '.json'))

def fixed_map(self, option):
# https://stackoverflow.com/a/62011081
Expand Down

0 comments on commit 9d5c9dc

Please sign in to comment.