Mercurial > repo
view bin/whatis @ 12320:9c7eb9899d95 draft
<fizzie> le/rn karma//All living beings have actions (karma) as their own, their inheritance, their congenital cause, their kinsman, their refuge. It is karma that differentiates beings into low and high states.
author | HackEso <hackeso@esolangs.org> |
---|---|
date | Fri, 06 Mar 2020 23:08:37 +0000 |
parents | 44379732c06b |
children |
line wrap: on
line source
#!/usr/bin/python3 import sys, os, 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(os.environ.get("HACKENV","/hackenv") + "/share/whatis", errors="surrogateescape") as whatisdb: for line in whatisdb: parts = re.match(r"([^()]+)\(([0-9A-Z_a-z])([0-9A-Z_a-z]*)\)", line) if parts: match = False for argind, argfold in enumerate(argfoldv): if (argfold == parts.group(1).casefold() or argfold == parts.group(1) + "(" + parts.group(2) + parts.group(3) + ")" or argfold == parts.group(1) + "(" + parts.group(3) + ")") \ : match = True foundv[argind] = True if match: print(line, end="") for arg, found in zip(argorg, foundv): if not found: print(arg + ": nothing appropriate.")