Skip to content

Commit

Permalink
Clear all
Browse files Browse the repository at this point in the history
- sff notes clear --all [@|file.sff]
- tests for this
- allow operations on multiple ids at once e.g. sff notes del -i 1,2,3,4 -D @
  • Loading branch information
Paul K. Korir, PhD committed Mar 23, 2018
1 parent 5705ed6 commit 18dae11
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
9 changes: 9 additions & 0 deletions sfftk/core/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,12 @@ def add_args(parser, the_arg):
add_args(clear_notes_parser, config_path)
add_args(clear_notes_parser, shipped_configs)
add_args(clear_notes_parser, sff_file)
clear_notes_parser.add_argument(
'--all',
action='store_true',
default=False,
help="clear all notes; USE WITH CARE!"
)
clear_notes_parser.add_argument(
'--from-global',
action='store_true',
Expand Down Expand Up @@ -1066,6 +1072,9 @@ def parse_args(_args):
args.segment_id = [from_segment]
else:
args.segment_id = from_segment
elif args.all:
args.from_global = True
args.from_all_segments = True

elif args.notes_subcommand == "merge":
if args.output is None:
Expand Down
3 changes: 0 additions & 3 deletions sfftk/notes/modify.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,6 @@ def add_note(args, configs):
sff_seg.segment = note.add_to_segment(segment)
print NoteView(sff_seg.segment, _long=True)
found_segment = True
break
if not found_segment:
print_date("Segment of ID(s) {} not found".format(", ".join(map(str, args.segment_id))))
# export
Expand Down Expand Up @@ -621,7 +620,6 @@ def edit_note(args, configs):
sff_seg.segment = note.edit_in_segment(segment)
print NoteView(sff_seg.segment, _long=True)
found_segment = True
break
if not found_segment:
print_date("Segment of ID(s) {} not found".format(", ".join(map(str, args.segment_id))))
# export
Expand Down Expand Up @@ -655,7 +653,6 @@ def del_note(args, configs):
sff_seg.segment = note.del_from_segment(segment)
print NoteView(sff_seg.segment, _long=True)
found_segment = True
break
if not found_segment:
print_date("Segment of ID(s) {} not found".format(", ".join(map(str, args.segment_id))))
# export
Expand Down
10 changes: 10 additions & 0 deletions sfftk/unittests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,16 @@ def test_clear_global_only(self):
args, _ = parse_args(shlex.split(cmd))
self.assertTrue(args.from_global)

def test_clear_all(self):
"""Test that we can clear all notes"""
cmd = "notes clear --all --config-path {config_fn} file.sff".format(
config_fn=self.config_fn,
)
args, _ = parse_args(shlex.split(cmd))
self.assertTrue(args.all)
self.assertTrue(args.from_global)
self.assertTrue(args.from_all_segments)

# =========================================================================
# notes: save
# =========================================================================
Expand Down

0 comments on commit 18dae11

Please sign in to comment.