__main__.py 680 字节
Newer Older
1 2 3 4 5 6 7
"""
Runnable module, can be executed as:
$ python -m stegano
"""

from .bitmap import Bitmap
from .cli import CommandLineArguments, parse_args
8 9
from .decoder import decode, DecodingError
from .encoder import encode, EncodingError
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
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())
27
    except (EncodingError, DecodingError) as ex:
28
        print(ex)