forked from realpython/materials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__main__.py
More file actions
28 lines (23 loc) · 680 Bytes
/
Copy path__main__.py
File metadata and controls
28 lines (23 loc) · 680 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
Runnable module, can be executed as:
$ python -m stegano
"""
from .bitmap import Bitmap
from .cli import CommandLineArguments, parse_args
from .decoder import decode, DecodingError
from .encoder import encode, EncodingError
from .eraser import erase
def main(args: CommandLineArguments) -> None:
"""Entry point to the script."""
with Bitmap(args.bitmap) as bitmap:
if args.encode:
encode(bitmap, args.encode)
elif args.decode:
decode(bitmap)
elif args.erase:
erase(bitmap)
if __name__ == "__main__":
try:
main(parse_args())
except (EncodingError, DecodingError) as ex:
print(ex)