2015 day 3.
This commit is contained in:
@@ -12,6 +12,12 @@ def main():
|
||||
parser.add_argument(
|
||||
"-u", "--user", type=str, default="holt59", help="user input to use"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--stdin",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="use stdin as input",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-i",
|
||||
"--input",
|
||||
@@ -26,6 +32,7 @@ def main():
|
||||
|
||||
verbose: bool = args.verbose
|
||||
test: bool = args.test
|
||||
stdin: bool = args.stdin
|
||||
user: str = args.user
|
||||
input_path: Path | None = args.input
|
||||
|
||||
@@ -42,8 +49,11 @@ def main():
|
||||
)
|
||||
assert input_path.exists(), f"{input_path} missing"
|
||||
|
||||
with open(input_path) as fp:
|
||||
sys.stdin = fp
|
||||
if stdin:
|
||||
importlib.import_module(f".{year}.day{day}", __package__)
|
||||
else:
|
||||
with open(input_path) as fp:
|
||||
sys.stdin = fp
|
||||
importlib.import_module(f".{year}.day{day}", __package__)
|
||||
|
||||
sys.stdin = sys.__stdin__
|
||||
sys.stdin = sys.__stdin__
|
||||
|
Reference in New Issue
Block a user