-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52f835e
commit 1a93126
Showing
9 changed files
with
152 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
""" | ||
Useful commands | ||
""" | ||
import os | ||
from .parser import get_only_parser | ||
|
||
|
||
def is_sequence_file(filename, extension, isfile): | ||
""" | ||
Is sequence file | ||
:param filename: filename | ||
:param extension: file extension | ||
""" | ||
return filename.endswith(f'.{extension}') and isfile(filename) | ||
|
||
|
||
def show_sequences(all_files, extension, isfile, show=print): | ||
""" | ||
Show sequence | ||
:param all_files: files to check | ||
:param extension: sequence file extension | ||
:param isfile: function to check not dir | ||
:param show: show function, default print | ||
""" | ||
for file in [file for file in all_files if is_sequence_file(file, extension, isfile)]: | ||
show(file) | ||
|
||
|
||
def sequence_list_cli(): | ||
""" | ||
Get sequence list | ||
""" | ||
parser = get_only_parser('wizard-list') | ||
parser.add_argument('-e', '--extension', default='sequence', type=str) | ||
|
||
args = parser.parse_args() | ||
|
||
extension = args.extension | ||
|
||
show_sequences(os.listdir(), extension, os.path.isfile, print) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
Package info | ||
""" | ||
name = 'replay-wizard' | ||
version = '2.1.0' | ||
version = '2.2.0' | ||
status = '4 - Beta' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
""" | ||
Sequence list command manual run | ||
""" | ||
from replay_wizard.__main__ import sequence_list | ||
|
||
|
||
if __name__ == '__main__': | ||
sequence_list() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
""" | ||
Test utils CLI module | ||
""" | ||
from unittest import mock | ||
from replay_wizard.cli.utils import is_sequence_file, show_sequences, sequence_list_cli | ||
|
||
|
||
def test_is_sequence_file(): | ||
""" | ||
Test is_sequence_file | ||
""" | ||
assert is_sequence_file('one.txt', 'txt', lambda x: True) | ||
assert is_sequence_file('one.txt', 'txt', lambda x: False) is False | ||
assert is_sequence_file('one.other', 'txt', lambda x: True) is False | ||
|
||
|
||
def test_show_sequences(): | ||
""" | ||
test show sequences | ||
""" | ||
def show(name): | ||
show.count += 1 | ||
show.files.append(name) | ||
|
||
show.count = 0 | ||
show.files = [] | ||
|
||
def is_file(name): | ||
return '.' in name | ||
|
||
all_files = ['one.s', 'two.s', 'dir', 'three.m'] | ||
show_sequences(all_files, 's', is_file, show) | ||
assert show.count == 2 | ||
assert show.files == ['one.s', 'two.s'] | ||
|
||
|
||
def test_sequence_list_cli(mock_list_argument_parser): | ||
""" | ||
Test CLI | ||
""" | ||
with mock.patch('argparse.ArgumentParser', mock_list_argument_parser): | ||
with mock.patch('os.listdir'): | ||
with mock.patch('os.path.isfile'): | ||
sequence_list_cli() |