Mercurial > repo
view bin/whatis @ 11969:df3a01142399 draft
<oerjan> le/rn Hungry//Hungry is a country in Europe, formerly part of the Ostrich empire. It split after a famine that got so severe that they had to start editing disgusting things like bell peppers. Absurdly, this became a tradition that continues until the present day.
author | HackEso <hackeso@esolangs.org> |
---|---|
date | Wed, 16 Oct 2019 08:34:37 +0000 |
parents | cc933fc31298 |
children | dff0129e4a40 |
line wrap: on
line source
#!/usr/bin/python3 import sys, re if len(sys.argv) <= 1: print("whatis what?") sys.exit(1) else: argorg = [] argfoldv = [] foundv = [] for arg in sys.argv[1:]: argorg.append(arg) argfoldv.append(arg.casefold()) foundv.append(False) 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 argind, argfold in enumerate(argfoldv): if argfold == parts.group(1).casefold(): match = True foundv[argind] = True if match: print(line, end="") for arg, found in zip(argorg, foundv): if not found: print(arg + ": nothing appropriate.")