Skip to content

Commit

Permalink
Merge pull request #3 from raganmd/dev
Browse files Browse the repository at this point in the history
Dev
Approved.
  • Loading branch information
raganmd authored Nov 16, 2018
2 parents f788a46 + 7116fdb commit 0818ecc
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 58 deletions.
Binary file modified dev/base_save.tox
Binary file not shown.
152 changes: 94 additions & 58 deletions dev/saveEXT.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, my_op):

return

def Save_tox(self, current_loc):
def Prompt_to_save(self, current_loc):
'''
The method used to save an external TOX to file
Expand All @@ -55,15 +55,17 @@ def Save_tox(self, current_loc):
none
'''

ext_color = parent().pars("Extcolor*")
msg_box_title = "TOX Save"
msg_box_msg = "Replacing External\n\nYou are about to overwite an exnteral TOX"
msg_box_buttons = ["Cancel", "Continue"]
ext_color = parent().pars("Extcolor*")
msg_box_title = "TOX Save"
msg_box_msg = "Replacing External\n\nYou are about to overwite an exnteral TOX"
msg_box_buttons = ["Cancel", "Continue"]

sav_msg_box_title = "Externalize Tox"
sav_msg_box_msg = "This TOX is not yet externalized\n\nWould you like to externalize this TOX?"
sav_msg_box_buttons = ["No", "Yes"]

save_msg_buttons_parent_too = ["No", "This COMP Only", "This COMP and the Parent"]

sav_msg_box_title = "Externalize Tox"
sav_msg_box_msg = "This TOX is not yet externalized\n\nWould you like to externalize this TOX?"
sav_msg_box_buttons = ["No", "Yes"]

# check if location is the root of the project
if current_loc == '/':
Expand All @@ -74,77 +76,111 @@ def Save_tox(self, current_loc):
# if we're not at the root of the project

# check if external
if current_loc.par.externaltox != "":

if current_loc.par.externaltox != '':
confirmation = ui.messageBox(msg_box_title, msg_box_msg, buttons = msg_box_buttons)

if confirmation:

# save external file
external_path = current_loc.par.externaltox
current_loc.save(external_path)

# set color for COMP
current_loc.color = (ext_color[0], ext_color[1], ext_color[2])

# flash color
self.Flash_bg("Bgcolor")

# create and print log message
log_msg = "{} saved to {}/{}".format(current_loc,
project.folder,
external_path)

self.Logtotextport(log_msg)

self.Save_over_tox(current_loc)

else:
# if the user presses "cancel" we pass
pass

# ask if we want to externalize the file
# in this case we are not external, so let's ask if we want to externalize the file
else:
save_ext = ui.messageBox(sav_msg_box_title, sav_msg_box_msg, buttons = sav_msg_box_buttons)

if save_ext:
# ask user for a save location
save_loc = ui.chooseFolder(title="TOX Location")

# construct a relative path and relative loaction for our elements
rel_path = tdu.collapsePath(save_loc)
rel_loc = '{new_module}/{new_tox}/{new_tox}.tox'.format(new_module = rel_path, new_tox = current_loc.name)

# check if the parent is externalized
if current_loc.parent().par.externaltox != '':
save_ext = ui.messageBox(sav_msg_box_title, sav_msg_box_msg, buttons = save_msg_buttons_parent_too)

# save this comp only
if save_ext == 1:
self.Save_tox()

# save this comp and the parent
elif save_ext == 2:
self.Save_tox(current_loc)
print("save this tox")

# save parent() COMP
self.Save_over_tox(current_loc.parent())
print("Save the parent too!")

# user selected 'No'
else:
pass

# the parent is not external, so let's ask about externalizing the tox
else:
save_ext = ui.messageBox(sav_msg_box_title, sav_msg_box_msg, buttons = sav_msg_box_buttons)

# create path and directory in the OS
new_path = '{selected_path}/{new_module}'.format(selected_path = save_loc, new_module = current_loc.name)
os.mkdir(new_path)
if save_ext:
self.Save_tox(current_loc)

# format our tox path
tox_path = '{dir_path}/{tox}.tox'.format(dir_path = new_path, tox = current_loc.name)
else:
# the user selected "No"
pass

# setup our module correctly
current_loc.par.externaltox = rel_loc
current_loc.par.savebackup = False

return

# set color for COMP
current_loc.color = (ext_color[0], ext_color[1], ext_color[2])
def Save_over_tox(self, current_loc):
ext_color = parent().pars("Extcolor*")
external_path = current_loc.par.externaltox
current_loc.save(external_path)

# save our tox
current_loc.save(tox_path)
# set color for COMP
current_loc.color = (ext_color[0], ext_color[1], ext_color[2])

# flash color
self.Flash_bg("Bgcolor")
# flash color
self.Flash_bg("Bgcolor")

# create and print log message
log_msg = "{} saved to {}/{}".format(current_loc,
project.folder,
tox_path)
self.Logtotextport(log_msg)
# create and print log message
log_msg = "{} saved to {}/{}".format(current_loc,
project.folder,
external_path)

self.Logtotextport(log_msg)

else:
# the user selected "No"
pass
return

def Save_tox(self, current_loc):
ext_color = parent().pars("Extcolor*")

# ask user for a save location
save_loc = ui.chooseFolder(title="TOX Location")

# construct a relative path and relative loaction for our elements
rel_path = tdu.collapsePath(save_loc)
rel_loc = '{new_module}/{new_tox}/{new_tox}.tox'.format(new_module = rel_path, new_tox = current_loc.name)

# create path and directory in the OS
new_path = '{selected_path}/{new_module}'.format(selected_path = save_loc, new_module = current_loc.name)
os.mkdir(new_path)

# format our tox path
tox_path = '{dir_path}/{tox}.tox'.format(dir_path = new_path, tox = current_loc.name)

# setup our module correctly
current_loc.par.externaltox = rel_loc
current_loc.par.savebackup = False

# set color for COMP
current_loc.color = (ext_color[0], ext_color[1], ext_color[2])

# save our tox
current_loc.save(tox_path)

# flash color
self.Flash_bg("Bgcolor")

# create and print log message
log_msg = "{} saved to {}/{}".format(current_loc,
project.folder,
tox_path)
self.Logtotextport(log_msg)
return

def Reload_ext_dat(self, external_file):
Expand Down
Binary file modified dev/save_tox.toe
Binary file not shown.
Binary file modified release/base_save.tox
Binary file not shown.
Binary file modified sample_project/sample_project.toe
Binary file not shown.
Binary file added sample_project/td-modules/base_my_fx/base_my_fx.tox
Binary file not shown.
Binary file modified sample_project/td-modules/container_output/container_output.tox
Binary file not shown.

0 comments on commit 0818ecc

Please sign in to comment.