merge
This commit is contained in:
@@ -4,4 +4,4 @@ import sys,os
|
|||||||
sys.path.append(os.path.realpath(os.path.join(os.path.dirname(__file__),
|
sys.path.append(os.path.realpath(os.path.join(os.path.dirname(__file__),
|
||||||
"..","reporting")))
|
"..","reporting")))
|
||||||
import ansi
|
import ansi
|
||||||
ansi.demo()
|
print(ansi.demo())
|
||||||
|
|||||||
@@ -142,4 +142,4 @@ ${S}=====================${Z}
|
|||||||
C .left() Left y;xH .pos() Absolute Position
|
C .left() Left y;xH .pos() Absolute Position
|
||||||
D .right() Right """
|
D .right() Right """
|
||||||
|
|
||||||
print(c.color_string(unformatted))
|
return(c.color_string(unformatted))
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import sys,os,re
|
import sys,os,re
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser, RawDescriptionHelpFormatter
|
||||||
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
|
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
|
||||||
import ansi
|
import ansi
|
||||||
|
|
||||||
@@ -16,12 +16,13 @@ def setup_options():
|
|||||||
usage = '''
|
usage = '''
|
||||||
Markdown syntax color in ansi codes.
|
Markdown syntax color in ansi codes.
|
||||||
Special syntaxes:
|
Special syntaxes:
|
||||||
Colors: insert string ${C}, where C is one of %s.
|
- Colors: insert string e.g. ${C}.
|
||||||
Any ANSI control code: ${3A}, ${1;34;42m}, etc..
|
- Any ANSI control code: ${3A}, ${1;34;42m}, see the table..
|
||||||
|
|
||||||
'''%(" ".join(bc.get_keys()))
|
''' + ansi.demo()
|
||||||
|
|
||||||
parser = ArgumentParser(
|
parser = ArgumentParser(
|
||||||
|
formatter_class = RawDescriptionHelpFormatter,
|
||||||
description = usage,
|
description = usage,
|
||||||
epilog = __author__
|
epilog = __author__
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ __author__ = "Ville Rantanen <ville.q.rantanen@gmail.com>"
|
|||||||
__version__ = "0.1"
|
__version__ = "0.1"
|
||||||
|
|
||||||
import sys,os,argparse,re
|
import sys,os,argparse,re
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
|
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
|
||||||
import ansi
|
import ansi
|
||||||
|
|
||||||
@@ -32,10 +32,10 @@ def setup_options():
|
|||||||
usage='''
|
usage='''
|
||||||
Color notation renderer in ANSI codes
|
Color notation renderer in ANSI codes
|
||||||
Special syntaxes:
|
Special syntaxes:
|
||||||
* Colors: insert string ${X}, where X is one of %s.
|
* Colors: insert string ${X}, where X values in the table below.
|
||||||
|
|
||||||
|
''' + ansi.demo()
|
||||||
|
|
||||||
'''%(" ".join(bc.get_keys()))
|
|
||||||
|
|
||||||
parser=ArgumentParser(description=usage,
|
parser=ArgumentParser(description=usage,
|
||||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||||
epilog=__author__)
|
epilog=__author__)
|
||||||
@@ -47,7 +47,7 @@ Special syntaxes:
|
|||||||
help="Reset coloring at the end of each line.")
|
help="Reset coloring at the end of each line.")
|
||||||
parser.add_argument("-Z",action="store_false",dest="zero_final",default=True,
|
parser.add_argument("-Z",action="store_false",dest="zero_final",default=True,
|
||||||
help="Disable reset of colors at the end of file.")
|
help="Disable reset of colors at the end of file.")
|
||||||
parser.add_argument("filename",type=str,
|
parser.add_argument("filename",type=str,
|
||||||
help="File to show, - for stdin")
|
help="File to show, - for stdin")
|
||||||
opts=parser.parse_args()
|
opts=parser.parse_args()
|
||||||
return opts
|
return opts
|
||||||
@@ -61,15 +61,17 @@ else:
|
|||||||
for row in f:
|
for row in f:
|
||||||
if not row:
|
if not row:
|
||||||
continue
|
continue
|
||||||
row=row.decode('utf-8').rstrip("\n\r ")
|
if type(row) == bytes:
|
||||||
|
row = row.decode('utf-8')
|
||||||
|
row=row.rstrip("\n\r ")
|
||||||
if opts.color:
|
if opts.color:
|
||||||
colored=bc.color_string(row)
|
colored=bc.color_string(row)
|
||||||
else:
|
else:
|
||||||
colored=bc.nocolor_string(row)
|
colored=bc.nocolor_string(row)
|
||||||
sys.stdout.write(colored.encode('utf-8'))
|
sys.stdout.write(colored)
|
||||||
if opts.zero and opts.color:
|
if opts.zero and opts.color:
|
||||||
sys.stdout.write(bc.Z)
|
sys.stdout.write(bc.Z)
|
||||||
sys.stdout.write("\n")
|
sys.stdout.write("\n")
|
||||||
if opts.zero_final and opts.color:
|
if opts.zero_final and opts.color:
|
||||||
sys.stdout.write(bc.Z.encode('utf-8'))
|
sys.stdout.write(bc.Z)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user