mirror of
https://github.com/david-schmidt/Davex.git
synced 2024-09-27 13:55:09 +00:00
Put the help aliases into index.py, so the caller can just loop over all the help files.
This commit is contained in:
parent
4903c10982
commit
abf2141c63
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
# index create indexed.help <index-size-in-bytes>
|
# index create indexed.help <index-size-in-bytes>
|
||||||
# index add indexed.help <text-file-to-add> [additional-entry-name-aliases-for-this-file]
|
# index add indexed.help <text-file-to-add>
|
||||||
|
|
||||||
# Format of an indexed file is:
|
# Format of an indexed file is:
|
||||||
#
|
#
|
||||||
@ -13,11 +13,11 @@
|
|||||||
# +052 start of index
|
# +052 start of index
|
||||||
#
|
#
|
||||||
# Index is:
|
# Index is:
|
||||||
# length-pfx'd string, offset(4), uncompressed-length(4)
|
# length-pfx'd string, offset(4), uncompressed-length-never-used(4)
|
||||||
# :
|
# :
|
||||||
# $00
|
# compressed data (in chunks of 5 or 8 bits), ending with an encoded $00
|
||||||
#
|
#
|
||||||
# Text chunks are terminated by a $00. The data
|
# Text chunks are terminated by a (compressed) $00. The data
|
||||||
# is compressed, with 16 common characters using
|
# is compressed, with 16 common characters using
|
||||||
# only 5 bits (%1xxxx), and the remaining ones
|
# only 5 bits (%1xxxx), and the remaining ones
|
||||||
# using 8 bits (%0xxxxxxx).
|
# using 8 bits (%0xxxxxxx).
|
||||||
@ -32,6 +32,33 @@ def Compress(ch):
|
|||||||
return "{:0>5b}".format(16 + fourBits)
|
return "{:0>5b}".format(16 + fourBits)
|
||||||
return "{:0>8b}".format(ch)
|
return "{:0>8b}".format(ch)
|
||||||
|
|
||||||
|
def ExtraNamesFor(entry):
|
||||||
|
extraNames = {
|
||||||
|
"bye" : [ "quit" ],
|
||||||
|
"cat" : [ "ls" ],
|
||||||
|
"cls" : [ "home" ],
|
||||||
|
"create" : [ "mkdir" ],
|
||||||
|
"como" : [ ">" ],
|
||||||
|
"delete" : [ "rm" ],
|
||||||
|
"echo" : [ " e" ],
|
||||||
|
"eject" : [ "ej" ],
|
||||||
|
"equal" : [ "=" ],
|
||||||
|
"exec" : [ "<" ],
|
||||||
|
"help" : [ "?" ],
|
||||||
|
"online" : [ "o" ],
|
||||||
|
"origin" : [ "or" ],
|
||||||
|
"pg" : [ "more" ],
|
||||||
|
"pathnames" : [ "path" ],
|
||||||
|
"prefix" : [ "cd" ],
|
||||||
|
"shareware" : [ "$" ],
|
||||||
|
"up" : [ "\\" ]
|
||||||
|
};
|
||||||
|
|
||||||
|
if entry in extraNames.keys():
|
||||||
|
return extraNames[entry]
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
verb = sys.argv[1]
|
verb = sys.argv[1]
|
||||||
indexFile = sys.argv[2]
|
indexFile = sys.argv[2]
|
||||||
|
|
||||||
@ -83,7 +110,7 @@ if verb == "add":
|
|||||||
outFile.write(struct.pack('i', addFileUncompressedSize))
|
outFile.write(struct.pack('i', addFileUncompressedSize))
|
||||||
|
|
||||||
# Optionally write additional index entries for the same text we are adding.
|
# Optionally write additional index entries for the same text we are adding.
|
||||||
for extraName in sys.argv[4:]:
|
for extraName in ExtraNamesFor(entryName):
|
||||||
outFile.write(struct.pack('B', len(extraName)))
|
outFile.write(struct.pack('B', len(extraName)))
|
||||||
outFile.write(bytes(extraName, "utf8"))
|
outFile.write(bytes(extraName, "utf8"))
|
||||||
outFile.write(struct.pack('i', offsetToNewText))
|
outFile.write(struct.pack('i', offsetToNewText))
|
||||||
|
Loading…
Reference in New Issue
Block a user