-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added support for Paths, Email and Passwords
- Loading branch information
Chandra Irugalbandara
committed
Jul 29, 2024
1 parent
91d64a1
commit fb20d16
Showing
4 changed files
with
124 additions
and
0 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,38 @@ | ||
"""Different Types of Inputs to use with argonauts.""" | ||
|
||
import os | ||
import re | ||
|
||
|
||
class Path: | ||
"""Path input with autocompletion.""" | ||
|
||
def __init__(self) -> None: | ||
"""Initialize Path input.""" | ||
pass | ||
|
||
@staticmethod | ||
def validate(path: str) -> bool: | ||
"""Validate the given path.""" | ||
return os.path.exists(path) | ||
|
||
|
||
class Password: | ||
"""Password input with masking.""" | ||
|
||
def __init__(self) -> None: | ||
"""Initialize Password input.""" | ||
pass | ||
|
||
|
||
class Email: | ||
"""Email input with validation.""" | ||
|
||
def __init__(self) -> None: | ||
"""Initialize Email input.""" | ||
pass | ||
|
||
@staticmethod | ||
def validate(email: str) -> bool: | ||
"""Validate the given email.""" | ||
return bool(re.match(r"[^@]+@[^@]+\.[^@]+", email)) |
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,25 @@ | ||
"""Example of using the new argonauts API.""" | ||
|
||
import time | ||
|
||
from argonauts import argonaut | ||
from argonauts.inputs import Email, Password, Path | ||
|
||
|
||
@argonaut(process_name="Please wait...") | ||
def login(email: Email, password: Password) -> None: | ||
"""Login with email and password.""" | ||
time.sleep(3) | ||
print(f"Logged in with {email}.") | ||
|
||
|
||
@argonaut(process_name="Loading Configurations...") | ||
def configure(config_path: Path) -> None: | ||
"""Configure with the given path.""" | ||
time.sleep(3) | ||
print(f"Configured with {config_path}.") | ||
|
||
|
||
if __name__ == "__main__": | ||
login() | ||
configure() |