aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--SimplyQrGen.py33
-rw-r--r--requirements.txt1
3 files changed, 35 insertions, 0 deletions
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] + " <text to put in qrcode>")
+
+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