From 666e57f18ad53946ef189addc729027421c5d0ae Mon Sep 17 00:00:00 2001 From: neodarz Date: Fri, 21 Jun 2019 13:44:08 +0200 Subject: Initial commit --- README.md | 1 + SimplyQrGen.py | 33 +++++++++++++++++++++++++++++++++ requirements.txt | 1 + 3 files changed, 35 insertions(+) create mode 100644 README.md create mode 100644 SimplyQrGen.py create mode 100644 requirements.txt diff --git a/README.md b/README.md new file mode 100644 index 0000000..1d47bf0 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +Ultra simple qr code generator based on the exemple of [nayuki's code generator](https://github.com/nayuki/QR-Code-generator) diff --git a/SimplyQrGen.py b/SimplyQrGen.py new file mode 100644 index 0000000..53f7c7d --- /dev/null +++ b/SimplyQrGen.py @@ -0,0 +1,33 @@ +from qrcodegen import QrCode, QrSegment +import sys + +def print_usage(): + """Print the usage help.""" + print("Usage:") + print(sys.argv[0] + " ") + +def gen_qr(text): + """Gen the QR Code based on the given text.""" + return QrCode.encode_text(text, QrCode.Ecc.LOW) + +def print_qr(qrcode): + """Prints the given QrCode object to the console.""" + border = 4 + for y in range(-border, qrcode.get_size() + border): + for x in range(-border, qrcode.get_size() + border): + print(u"\u2588 "[1 if qrcode.get_module(x,y) else 0] * 2, end="") + print() + print() + +def main(): + """The main application program.""" + if len(sys.argv) == 2: + if sys.argv[1] != "": + print_qr(gen_qr(sys.argv[1])) + else: + print_usage() + else: + print_usage() + +if __name__ == "__main__": + main() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..dfac48f --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +qrcodegen==1.4.0 -- cgit v1.2.1