Mercurial > repo
comparison bin/whatis @ 11848:fb7d032ba453 draft
<wob_jonas> fetch bin/whatis https://hack.esolangs.org/get/bin/whatis
author | HackEso <hackeso@esolangs.org> |
---|---|
date | Tue, 16 Jul 2019 15:16:11 +0000 |
parents | |
children | cfb04b3810bf |
comparison
equal
deleted
inserted
replaced
11847:0a849e804948 | 11848:fb7d032ba453 |
---|---|
1 #!/usr/bin/python3 | |
2 import sys, re | |
3 if len(sys.argv) <= 1: | |
4 print("whatis what?") | |
5 sys.exit(1) | |
6 else: | |
7 argfoldv = [] | |
8 for arg in sys.argv[1:]: | |
9 argfoldv.append(arg.casefold()) | |
10 with open("/hackenv/share/whatis", errors="surrogateescape") as whatisdb: | |
11 for line in whatisdb: | |
12 parts = re.match(r"([^()]+)\(([0-9A-Z_a-z]+)\)", line) | |
13 if parts: | |
14 match = False | |
15 for argfold in argfoldv: | |
16 match = match or argfold == parts[1].casefold() | |
17 if match: | |
18 sys.stdout.write(line) | |
19 |