Mercurial > repo
view bin/whatis @ 11850:cfb04b3810bf draft
<wob_jonas> fetch bin/whatis https://hack.esolangs.org/get/bin/whatis
author | HackEso <hackeso@esolangs.org> |
---|---|
date | Tue, 16 Jul 2019 15:18:48 +0000 |
parents | fb7d032ba453 |
children | 97b02eed7f57 |
line wrap: on
line source
#!/usr/bin/python3 import sys, re if len(sys.argv) <= 1: print("whatis what?") sys.exit(1) else: argfoldv = [] for arg in sys.argv[1:]: argfoldv.append(arg.casefold()) with open("/hackenv/share/whatis", errors="surrogateescape") as whatisdb: for line in whatisdb: parts = re.match(r"([^()]+)\(([0-9A-Z_a-z]+)\)", line) if parts: match = False for argfold in argfoldv: match = match or argfold == parts.group(1).casefold() if match: sys.stdout.write(line)