cleanups
This commit is contained in:
parent
0bc4c4f06e
commit
32272b93b3
@ -1731,8 +1731,13 @@ async def file_picker(suffix=None, min_size=1, max_size=1000000, taster=None,
|
||||
# - escape: allow these chars to skip picking process
|
||||
# - slot_b: None=>pick slot w/ card in it, or A if both.
|
||||
# - allow_batch: adds an "all of the above" choice: ("menu label", menu_handler)
|
||||
# suffix argument MUST contain the dot (.), if list of suffixes - all MUST contain the dot
|
||||
# - suffix argument MUST contain the dot (.txt), if list of suffixes, all MUST
|
||||
|
||||
if suffix:
|
||||
# actually make it a list of "suffixes"
|
||||
if not isinstance(suffix, list):
|
||||
suffix = [suffix]
|
||||
assert all(s[0] == '.' for s in suffix)
|
||||
|
||||
if choices is None:
|
||||
choices = []
|
||||
@ -1746,15 +1751,13 @@ async def file_picker(suffix=None, min_size=1, max_size=1000000, taster=None,
|
||||
# ignore subdirs
|
||||
continue
|
||||
|
||||
if suffix:
|
||||
if not isinstance(suffix, list):
|
||||
suffix = [suffix]
|
||||
if fn[0] == '.':
|
||||
# unix-style hidden files
|
||||
continue
|
||||
|
||||
assert all(s[0] == "." for s in suffix)
|
||||
if not any([fn.lower().endswith(s) for s in suffix]):
|
||||
continue
|
||||
|
||||
if fn[0] == '.': continue
|
||||
if suffix and not any(fn.lower().endswith(s) for s in suffix):
|
||||
# wrong suffix, skip
|
||||
continue
|
||||
|
||||
full_fname = path + '/' + fn
|
||||
|
||||
@ -1800,7 +1803,7 @@ async def file_picker(suffix=None, min_size=1, max_size=1000000, taster=None,
|
||||
if none_msg:
|
||||
msg += none_msg
|
||||
if suffix:
|
||||
msg += '\n\nThe filename must end in: %s' % ",".join(["*" + s for s in suffix])
|
||||
msg += '\n\nThe filename must end in: ' + ' OR '.join(suffix)
|
||||
|
||||
msg += '\n\nMaybe insert (another) SD card and try again?'
|
||||
|
||||
|
||||
@ -1172,7 +1172,7 @@ def test_file_picker_suffixes(pick_menu_item, goto_home, cap_story, microsd_wipe
|
||||
time.sleep(.1)
|
||||
_, story = cap_story()
|
||||
assert "No suitable files found" in story
|
||||
assert "The filename must end in: *.7z,*.txt" in story
|
||||
assert "The filename must end in: .7z OR .txt" in story
|
||||
press_select()
|
||||
|
||||
goto_home()
|
||||
@ -1183,7 +1183,7 @@ def test_file_picker_suffixes(pick_menu_item, goto_home, cap_story, microsd_wipe
|
||||
time.sleep(.1)
|
||||
_, story = cap_story()
|
||||
assert "No suitable files found" in story
|
||||
assert "The filename must end in: *.pdf" in story
|
||||
assert "The filename must end in: .pdf" in story
|
||||
|
||||
goto_home()
|
||||
pick_menu_item("Advanced/Tools")
|
||||
@ -1192,7 +1192,7 @@ def test_file_picker_suffixes(pick_menu_item, goto_home, cap_story, microsd_wipe
|
||||
time.sleep(.1)
|
||||
_, story = cap_story()
|
||||
assert "No suitable files found" in story
|
||||
assert "The filename must end in: *.txt,*.json" in story
|
||||
assert "The filename must end in: .txt OR .json" in story
|
||||
microsd_wipe()
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user