-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rough workaround for the need to login with real user&pass to dow…
…nload attachments.
- Loading branch information
Showing
6 changed files
with
85 additions
and
22 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 |
---|---|---|
|
@@ -13,15 +13,19 @@ def __init__(self, controller_factory, controller_dependencies_factory): | |
self.__controller = None | ||
|
||
@staticmethod | ||
def __add_token_group(parser): | ||
def __add_authorization_group(parser): | ||
token_group = parser.add_mutually_exclusive_group(required=True) | ||
token_group.add_argument("--token", type=str, | ||
help="todoist API token (see Settings --> Integration)") | ||
token_group.add_argument("--token-file", type=str, | ||
help="file containing the todoist API token") | ||
parser.add_argument("--email", type=str, | ||
help="todoist email address for authorization") | ||
parser.add_argument("--password", type=str, | ||
help="todoist email address for authorization") | ||
|
||
def __parse_command_line_args(self, prog, arguments): | ||
example1_str = "Example: {} download --token 0123456789abcdef".format(prog) | ||
example1_str = "Example: {} download --token 0123456789abcdef --email [email protected] --password P4ssW0rD".format(prog) | ||
parser = argparse.ArgumentParser(prog=prog, formatter_class=argparse.RawTextHelpFormatter, | ||
epilog=example1_str) | ||
parser.add_argument("--verbose", action="store_true", help="print details to console") | ||
|
@@ -35,7 +39,7 @@ def __parse_command_line_args(self, prog, arguments): | |
help="download attachments and attach to the backup file") | ||
parser_download.add_argument("--output-file", type=str, | ||
help="name of the file that will store the backup") | ||
self.__add_token_group(parser_download) | ||
self.__add_authorization_group(parser_download) | ||
|
||
return parser.parse_args(arguments) | ||
|
||
|
@@ -45,18 +49,18 @@ def run(self, prog, arguments): | |
args.func(args) | ||
|
||
@staticmethod | ||
def __get_token(args): | ||
if args.token_file: | ||
return Path(args.token_file).read_text() | ||
|
||
return args.token | ||
def __get_auth(args): | ||
token = Path(args.token_file).read_text() if args.token_file else args.token | ||
email = args.email | ||
password = args.password | ||
return {"token": token, "email": email, "password": password} | ||
|
||
def handle_download(self, args): | ||
""" Handles the download subparser with the specified command line arguments """ | ||
|
||
# Configure controller | ||
token = self.__get_token(args) | ||
dependencies = self.__controller_dependencies_factory(token, args.verbose) | ||
auth = self.__get_auth(args) | ||
dependencies = self.__controller_dependencies_factory(auth, args.verbose) | ||
controller = self.__controller_factory(dependencies) | ||
|
||
# Setup zip virtual fs | ||
|
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