Skip to content

Commit

Permalink
Merge pull request #332 from DeepSenseCA/bug_edit-line
Browse files Browse the repository at this point in the history
BUG: Overwriting existing line
  • Loading branch information
scottclowe committed Nov 18, 2022
2 parents 2c2cd8f + 6517030 commit 397bef5
Showing 1 changed file with 82 additions and 34 deletions.
116 changes: 82 additions & 34 deletions echofilter/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -1651,23 +1651,47 @@ def change_line_color_thickness(line_name, color, thickness, ev_app=ev_app):
f" {key} line output"
)
)
old_line_edit = old_line.AsLineEditable
if old_line_edit:
# Overwrite the old line with the new line
old_line_edit.OverwriteWith(line)
# Delete the line we imported
lines.Delete(line)
# Update our reference to the line
line = old_line
successful_overwrite = True
elif verbose >= 0:
# Line is not editable
s = (
f"Existing line '{target_name}' is not editable and"
" cannot be overwritten."
)
s = echofilter.ui.style.warning_fmt(s)
print(s)
try:
old_line_edit = old_line.AsLineEditable()
if old_line_edit:
# Overwrite the old line with the new line
old_line_edit.OverwriteWith(line)
# Delete the line we imported
lines.Delete(line)
# Update our reference to the line
line = old_line
successful_overwrite = True
except Exception as err:
if verbose >= 3:
# Line is not editable
s = (
f"An error occurred while trying to overwrite existing line '{target_name}':"
f"\n{old_line_edit}"
f"\n{err}"
)
s = echofilter.ui.style.warning_fmt(s)
print(s)
if not successful_overwrite:
try:
# Just delete the old line (seems like a simpler solution)
lines.Delete(old_line)
successful_overwrite = True
except Exception as err:
if verbose >= 3:
# Line could not be deleted
s = (
f"An error occurred while trying to delete existing line '{target_name}':"
f"\n{old_line}"
f"\n{err}"
)
s = echofilter.ui.style.warning_fmt(s)
print(s)
if not successful_overwrite and verbose >= 0:
if verbose >= 0:
# Line is not editable
s = f"Existing line '{target_name}' cannot be overwritten."
s = echofilter.ui.style.warning_fmt(s)
print(s)

if old_line and not successful_overwrite:
# Change the name so there is no collision
Expand Down Expand Up @@ -1788,23 +1812,47 @@ def change_line_color_thickness(line_name, color, thickness, ev_app=ev_app):
f" {key} line output"
)
)
old_line_edit = old_line.AsLineEditable
if old_line_edit:
# Overwrite the old line with the new line
old_line_edit.OverwriteWith(line)
# Delete the line we imported
lines.Delete(line)
# Update our reference to the line
line = old_line
successful_overwrite = True
elif verbose >= 0:
# Line is not editable
s = (
f"Existing line '{target_name}' is not editable and"
" cannot be overwritten."
)
s = echofilter.ui.style.warning_fmt(s)
print(s)
try:
old_line_edit = old_line.AsLineEditable()
if old_line_edit:
# Overwrite the old line with the new line
old_line_edit.OverwriteWith(line)
# Delete the line we imported
lines.Delete(line)
# Update our reference to the line
line = old_line
successful_overwrite = True
except Exception as err:
if verbose >= 3:
# Line is not editable
s = (
f"An error occurred while trying to overwrite existing line '{target_name}':"
f"\n{old_line_edit}"
f"\n{err}"
)
s = echofilter.ui.style.warning_fmt(s)
print(s)
if not successful_overwrite:
try:
# Just delete the old line (seems like a simpler solution)
lines.Delete(old_line)
successful_overwrite = True
except Exception as err:
if verbose >= 3:
# Line could not be deleted
s = (
f"An error occurred while trying to delete existing line '{target_name}':"
f"\n{old_line}"
f"\n{err}"
)
s = echofilter.ui.style.warning_fmt(s)
print(s)
if not successful_overwrite and verbose >= 0:
if verbose >= 0:
# Line is not editable
s = f"Existing line '{target_name}' cannot be overwritten."
s = echofilter.ui.style.warning_fmt(s)
print(s)

if old_line and not successful_overwrite:
# Change the name so there is no collision
Expand Down

0 comments on commit 397bef5

Please sign in to comment.