short format. cp list could be just free str...
This commit is contained in:
@@ -6,25 +6,29 @@ from argparse import ArgumentParser
|
||||
|
||||
def setup_options():
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument("cs",type=str, default = "cp437", nargs = '?',
|
||||
choices = ["cp437", "latin1", "cp850"]
|
||||
parser.add_argument(
|
||||
"-v",
|
||||
default = False,
|
||||
action = "store_true"
|
||||
)
|
||||
parser.add_argument(
|
||||
"cs",
|
||||
type = str,
|
||||
default = "cp437",
|
||||
nargs = '?',
|
||||
choices = [
|
||||
"ascii",
|
||||
"cp437",
|
||||
"cp850",
|
||||
"cp1250",
|
||||
"latin1",
|
||||
]
|
||||
)
|
||||
opts=parser.parse_args()
|
||||
return opts
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
opts = setup_options()
|
||||
table=[[] for x in range(8)]
|
||||
for c in range(0,256):
|
||||
col = c/32
|
||||
table[col].append((c,chr(c).decode(opts.cs).encode('utf-8','ignore')))
|
||||
#sys.stdout.write(chr(c).decode('latin1'))
|
||||
# remove control chars
|
||||
table.pop(0)
|
||||
def long_format(table):
|
||||
bc = ansi.code()
|
||||
bc.clear()
|
||||
print(bc.color_string("="*20 + " ${Y}%s${Z} "%( opts.cs, ) + "="*20))
|
||||
for x,col in enumerate(table):
|
||||
for y,row in enumerate(col):
|
||||
bc.posprint(
|
||||
@@ -34,5 +38,37 @@ if __name__ == "__main__":
|
||||
"${c}%03d: ${G}%s${Z}"%( row )
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def short_format(table):
|
||||
bc = ansi.code()
|
||||
for x,col in enumerate(table):
|
||||
for y,row in enumerate(col):
|
||||
bc.posprint(
|
||||
x + 3,
|
||||
y * 2 + 1,
|
||||
bc.color_string(
|
||||
"${G}%s${Z}"%( row[1], )
|
||||
)
|
||||
)
|
||||
print('')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
opts = setup_options()
|
||||
table=[[] for x in range(8)]
|
||||
for c in range(0,256):
|
||||
col = c/32
|
||||
table[col].append((c,chr(c).decode(opts.cs,'ignore').encode('utf-8','ignore')))
|
||||
#sys.stdout.write(chr(c).decode('latin1'))
|
||||
# remove control chars
|
||||
table.pop(0)
|
||||
bc = ansi.code()
|
||||
bc.clear()
|
||||
print(bc.color_string("="*20 + " ${Y}%s${Z} "%( opts.cs, ) + "="*20))
|
||||
if opts.v:
|
||||
long_format(table)
|
||||
else:
|
||||
short_format(table)
|
||||
print('')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user