-
-
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.
Merge pull request #21 from quillcraftsman/models
Models
- Loading branch information
Showing
30 changed files
with
653 additions
and
283 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
""" | ||
Manual run module | ||
""" | ||
from replay_wizard.__main__ import capture | ||
|
||
|
||
if __name__ == '__main__': | ||
capture() |
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 @@ | ||
""" | ||
Manual run module | ||
""" | ||
from replay_wizard.__main__ import combine | ||
|
||
|
||
if __name__ == '__main__': | ||
combine() |
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,8 @@ | ||
""" | ||
Manual run module | ||
""" | ||
from replay_wizard.__main__ import replay | ||
|
||
|
||
if __name__ == '__main__': | ||
replay() |
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 |
---|---|---|
@@ -1,15 +1,25 @@ | ||
""" | ||
Package console entrypoint | ||
""" | ||
from replay_wizard.cli.app import run_cli | ||
from replay_wizard.cli import capture_cli, replay_cli, combine_cli | ||
|
||
|
||
def main(): | ||
def capture(): | ||
""" | ||
main function to run CLI for package | ||
capture CLI | ||
""" | ||
run_cli() | ||
capture_cli() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() | ||
def replay(): | ||
""" | ||
replay CLI | ||
""" | ||
replay_cli() | ||
|
||
|
||
def combine(): | ||
""" | ||
combine CLI | ||
""" | ||
combine_cli() |
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,6 @@ | ||
""" | ||
CLI package | ||
""" | ||
from .replay import replay_cli | ||
from .capture import capture_cli | ||
from .combine import combine_cli |
This file was deleted.
Oops, something went wrong.
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,29 @@ | ||
""" | ||
App CLI module | ||
""" | ||
import time | ||
from replay_wizard import capture | ||
from replay_wizard.storage import save_to_file | ||
from .parser import get_parser, add_arguments | ||
|
||
|
||
def capture_cli(): | ||
""" | ||
Run capture CLI wizard-capture | ||
""" | ||
|
||
parser = get_parser('wizard-capture') | ||
parser = add_arguments(parser) | ||
|
||
args = parser.parse_args() | ||
|
||
sequence_name = args.sequence | ||
delay = args.delay | ||
timedelta = args.timedelta | ||
keyboard = args.keyboard | ||
mouse = args.mouse | ||
|
||
time.sleep(delay) | ||
|
||
sequence = capture(sequence_name, timedelta, keyboard=keyboard, mouse=mouse) | ||
save_to_file(sequence) |
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,29 @@ | ||
""" | ||
Combine CLI | ||
""" | ||
from replay_wizard.models import get_sequence | ||
from replay_wizard.storage import load_from_file, save_to_file | ||
from .parser import get_parser | ||
|
||
|
||
def combine_cli(): | ||
""" | ||
Combine CLI function | ||
""" | ||
|
||
parser = get_parser('wizard-combine') | ||
parser.add_argument('sequences', nargs='+') | ||
args = parser.parse_args() | ||
|
||
sequence_name = args.sequence | ||
sequence_names = args.sequences | ||
true_time = args.timedelta | ||
|
||
sequences = [] | ||
for name in sequence_names: | ||
sequence = load_from_file(name, true_time=true_time) | ||
sequences.append(sequence) | ||
|
||
sequence_cls = get_sequence(true_time) | ||
new_sequence = sequence_cls.combine(sequence_name, *sequences) | ||
save_to_file(new_sequence) |
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,48 @@ | ||
""" | ||
Parser module | ||
""" | ||
import argparse | ||
|
||
PROGRAM_DESCRIPTION = """ | ||
ReplayWizard is a powerful automation tool designed to streamline your workflow by capturing | ||
and replaying your interactions with your computer | ||
""" | ||
|
||
|
||
def str2bool(v): | ||
""" | ||
Console bool parameter to bool python value | ||
""" | ||
if isinstance(v, bool): | ||
return v | ||
if v.lower() in ('yes', 'true', 't', 'y', '1'): | ||
return True | ||
if v.lower() in ('no', 'false', 'f', 'n', '0'): | ||
return False | ||
raise argparse.ArgumentTypeError('Boolean value expected.') | ||
|
||
|
||
def get_parser(command_name): | ||
""" | ||
Get argument parser | ||
""" | ||
parser = argparse.ArgumentParser( | ||
prog=command_name, | ||
description=PROGRAM_DESCRIPTION, | ||
epilog=f'Use {command_name} -h to get help' | ||
) | ||
|
||
parser.add_argument('sequence') | ||
parser.add_argument('-t', '--timedelta', default=False, type=str2bool) | ||
|
||
return parser | ||
|
||
|
||
def add_arguments(parser): | ||
""" | ||
Add same arguments | ||
""" | ||
parser.add_argument('-d', '--delay', default=0, type=int) | ||
parser.add_argument('-k', '--keyboard', default=True, type=str2bool) | ||
parser.add_argument('-mo', '--mouse', default=False, type=str2bool) | ||
return parser |
Oops, something went wrong.