示例#1
0
文件: tst.py 项目: ihgazni2/minidoc
def tst2kvlist(**kwargs):
    if ("codec" in kwargs):
        codec = kwargs["codec"]
    else:
        codec = "utf-8"
    if ("code" in kwargs):
        code = kwargs["code"]
    else:
        code = fs.rfile(kwargs["fn"])
    code = code + "\n#"
    g = tokenize(BytesIO(code.encode(codec)).readline)
    info = next(g)
    kl = []
    vl = []
    k = ""
    infos = [info]
    for info in g:
        if (info.type == COMMENT):
            kl.append(k)
            v = _infos2group(infos)
            vl.append(v)
            k = info.string.lstrip("#")
            infos = []
        else:
            infos.append(info)
    indexes = elel.cond_select_indexes_all(kl, cond_func=lambda ele: ele == "")
    kl = elel.pop_indexes(kl, indexes)['list']
    vl = elel.pop_indexes(vl, indexes)['list']
    return ((kl, vl))
示例#2
0
文件: htmlq.py 项目: ihgazni2/ecli
def load(o):
    h = ''
    try:
        h = fs.rfile(o)
    except:
        h = o
    else:
        pass
    return (h)
def main():
    projhd = tst.creat_projhd(args.proj_name,args.proj_desc)
    install = tst.creat_install(args.proj_name)
    license = tst.creat_license(args.proj_lic)
    src = (args.proj_name+".py") if(args.src_file=="") else args.src_file
    cd = fs.rfile(src)
    usage = creat_usage_from_code(cd)
    rst_str = projhd + install + license + usage
    dst = (args.proj_name+".rst") if(args.dst_file=="") else args.dst_file
    fs.wfile(dst,rst_str,codec=args.codec)
示例#4
0
def _cfgfile2pl(cfgfile):
    suffix = os.path.splitext(cfgfile)[1]
    if (suffix == ".rst"):
        rst_str = fs.rfile(cfgfile)
        dirs = rstcfg.get_dirs(rst_str)
    elif (suffix == ".json"):
        d = fs.rjson(cfgfile)
        dirs = jsoncfg.get_dirs(d)
    else:
        print("error,must be .rst or .json")
    return (dirs)
示例#5
0
def rplc_ver():
    s = fs.rfile("./setup.py")
    lines = s.split("\n")
    for i in range(len(lines)):
        if("#@version@#" in lines[i]):
            line = lines[i]
            lines[i] = update_one(line)
            break
        else:
            pass
    s = ""
    for i in range(len(lines)):
        s = s + lines[i] + "\n"
    fs.wfile("./setup.py",s)
示例#6
0
def load(o):
    j=None
    try:
        j = fs.rjson(o)
    except:
        try:
            s = fs.rfile(o)
            j = eval(s)
        except:
            j = eval(o)    
        else:
            pass        
    else:
        pass
    return(j)
示例#7
0
def main():
    global s
    global f
    global r
    unhandled = []
    if (s):
        unhandled = s.split(',')
    elif (f):
        try:
            unhandled = fs.rjson(f)
        except:
            s = fs.rfile(f)
            s = s.strip('\n')
            unhandled = s.split('\n')
        else:
            pass
    else:
        pass
    print(unhandled)
    abbr = get_word_abbr(unhandled)
    pobj(abbr)
示例#8
0
from xdict.jprint import pobj
from xdict.jprint import pdir
from xdict.cmdline import Hentry
from efuntool.efuntool import dflt_sysargv
import sys
from efdir import fs

html_text = fs.rfile(sys.argv[1])
match = dflt_sysargv('', 2)
style = dflt_sysargv('flat', 3)


# init a Hentry
def main():
    htry = Hentry(html_text=html_text)
    html_entry = htry.query(match, style=style)
示例#9
0
from xdict.jprint import pobj 
from efdir import fs
import efuntool.efuntool as eftl
import sys
import elist.elist as elel
import estring.estring as eses

src = sys.argv[1]
s = fs.rfile(src)


dst = sys.argv[2]


start = int(eftl.dflt_sysargv(1,3)) - 1


line_sp = '\n' 
lines =  eses.split(s,line_sp) if(line_sp in s) else [s]
lngth = len(lines)


end = int(eftl.dflt_sysargv(lngth+1,4)) - 1




def main():
    global lines 
    lines = lines[start:end]
    s = elel.join(lines,line_sp)
示例#10
0
def replace_each(fn):
    s = fs.rfile(fn)
    for each in PARAMS:
        s = s.replace("@" + each + "@", ARGS.__getattribute__(each))
    fs.wfile(fn, s)
示例#11
0
import elist.elist as elel
from efdir import fs
import sys
s = fs.rfile(sys.argv[1])

示例#12
0
文件: pobj.py 项目: ihgazni2/ecli
parser.add_argument('-quotes',
                    '-quotes',
                    default='\'\'\"\"',
                    help='quote pairs')


def boolstr2bool(s):
    if (s.lower() == 'false'):
        return (False)
    else:
        return (True)


args = parser.parse_args()
p = args.path
d = fs.rfile(p) if (fs.filexist(p)) else p
d = eval(d)
start = int(args.start)
end = int(args.end)
indent = int(args.indent)
fixed_indent = boolstr2bool(args.fixed_indent)
with_color = boolstr2bool(args.with_color)
key_color = args.key_color
value_color = args.value_color
list_ele_color = args.list_ele_color
op_color = args.op_color
default_color = args.default_color
sp = args.sp
line_sps = args.line_sps.split(',')
path_sps = args.path_sps.split(',')
commas = args.commas.split('/')
示例#13
0
from conjugar.acentuacion import *
from efdir import fs
s = fs.rfile('words.cat')
lines = s.strip().split('\n')
from xlist.map import mapv

arr = []
fails = []
for word in lines:
    print(word)
    try:
        var = get_silabas(word)
        arr = arr + var
    except:
        fails = fails + [word]
    else:
        pass

from xlist.util import uniqualize

arr = uniqualize(arr)