Skip to content

Instantly share code, notes, and snippets.

@st3b1t
Last active February 21, 2024 17:17
Show Gist options
  • Save st3b1t/373e1e595a350f4fbf056940cbb1f848 to your computer and use it in GitHub Desktop.
Save st3b1t/373e1e595a350f4fbf056940cbb1f848 to your computer and use it in GitHub Desktop.
commandline qrcode generator
#!/usr/bin/python3
# EASY-INSTALL-ENTRY-SCRIPT: 'qrcode==7.3.1','console_scripts','qr'
#
# requirements: pip install qrcode
import re
import sys
__requires__ = 'qrcode==7.3.1'
try:
from importlib.metadata import distribution
except ImportError:
try:
from importlib_metadata import distribution
except ImportError:
from pkg_resources import load_entry_point
def importlib_load_entry_point(spec, group, name):
dist_name, _, _ = spec.partition('==')
matches = (
entry_point
for entry_point in distribution(dist_name).entry_points
if entry_point.group == group and entry_point.name == name
)
return next(matches).load()
globals().setdefault('load_entry_point', importlib_load_entry_point)
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(load_entry_point('qrcode==7.3.1', 'console_scripts', 'qr')())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment