예제 #1
0
파일: common.py 프로젝트: ihgazni2/nvhead
 def append(self, *args):
     if (args.__len__() == 1):
         if (isinstance(args[0], dict)):
             self.darr.append(args[0])
             self.sarr = language_locale_q_darr2sarr(args[0])
         elif ('-' in args[0]):
             self.sarr.append(args[0])
             self.darr = language_locale_q_sarr2darr(self.sarr)
         else:
             print("invalid")
     elif (args.__len__() == 2):
         if (isinstance(args[1], str)):
             self.darr.append({
                 "language": args[0],
                 "locale": args[1],
                 "q": None
             })
         else:
             self.darr.append({
                 "language": args[0],
                 "locale": None,
                 "q": str(args[1])
             })
         self.sarr = language_locale_q_darr2sarr(self.darr)
     elif (args.__len__() == 3):
         self.darr.append({
             "language": args[0],
             "locale": args[1],
             "q": str(args[2])
         })
         self.sarr = language_locale_q_darr2sarr(self.darr)
     pobj(self.sarr)
예제 #2
0
파일: head.py 프로젝트: ihgazni2/nvhead
 def __repr__(self):
     if(self.for_req):
         pobj(self._dict)
     else:
         sarr = head_tl2sarr(self._tlist.tl)
         pobj(sarr)
     return("")
예제 #3
0
def get_vhabitat():
    # vhabitat = {}
    # eles = root.xpath('//input[@name="vhabitat"]')
    # for i in range(0,eles.__len__()):
    # ele = eles[i]
    # value = ele.get('value')
    # text = ele.text()
    # vhabitat[value] = text
    # vhabitat[text] = value
    # return(vhabitat)
    vhabitat = {
        'All': 'alpha2',
        'Freshwater': 'fresh',
        'Saltwater': 'saltwater',
        'Introduced': 'introduced',
        'Endemic': 'endemic',
        'Threatened': 'threatened',
        'Dangerous': 'dangerous',
        'Reef-associated': 'reef',
        'Pelagic': 'pelagic',
        'Deep-water': 'deepwater',
        'Game fishes': 'sports',
        'Commercial': 'commercial'
    }
    pobj(vhabitat)
    return (vhabitat)
예제 #4
0
파일: search.py 프로젝트: ihgazni2/conjugar
def search(arr, s):
    indexes = elel.cond_select_indexes_all(arr,
                                           cond_func=cond_search,
                                           cond_func_args=[s])
    values = elel.select_indexes(arr, indexes)
    pobj(values, with_color=0)
    return (values)
예제 #5
0
def do_actions():
    arr = sys.argv[1:]
    if(arr[0] == '-help'):
        s = '''
            #read from params,-login must be the first
            python3 mw316r.py -login -ip "192.168.1.1" -pw "lidapeng" 
            #read from config.cfg
            python3 mw316r.py -login
            python3 mw316r.py -status
            python3 mw316r.py -status wan
            python3 mw316r.py -status lan
            python3 mw316r.py -status wlan
            python3 mw316r.py -status general
            python3 mw316r.py -status wan_stats
            python3 mw316r.py -status wlan wan lan
        '''
        print(s)
    elif(arr[0] == '-login'):
        ckstr = login()
        nvft.write_to_file(fn="ckstr.record",op="w+",content=ckstr)
    elif(arr[0] == '-status'):
        ckstr = load_ckstr()
        params = arr[1:]
        lngth = params.__len__()
        if(lngth == 0):
            d = get_status(ckstr)
            pobj(d)
        else:
            params = elel.array_map(params,lambda ele:ACTIONS['status'][ele])
            d = get_status(ckstr)
            for key in params:
                pobj(d[key])
    elif(arr[0] == '-connect'):
예제 #6
0
 def __dir__(self):
     l = [
         'readable_path', 'pathlist', 'depth', 'breadth', 'siblings_seq',
         'tag', 'attrib', 'text', 'type', 'leaf', 'leaf_sons',
         'nonleaf_sons', 'leaf_descendants', 'nonleaf_descendants'
     ]
     jprint.pobj(l)
     return (l)
예제 #7
0
def main():
    word = sys.argv[1]
    print('-----------------------------')
    acen.show_stress(word)
    print('-----------------------------')
    pobj(acen.get_stress(word))
    print('-----------------------------')
    print(acen.get_silabas(word))
예제 #8
0
def main():
    j = load(sys.argv[1])
    pl = sys.argv[2:]
    cmdk = elel.join(pl,' ')
    cmdt = cmdline.cmdict(dict=j,debug=0)
    r = cmdt[cmdk]
    if(r):
        pobj(r)
    else:
        pass
예제 #9
0
def gen_show_mat(mat, rtrn=False):
    for i in range(0, mat.__len__()):
        level = mat[i]
        for j in range(0, level.__len__()):
            if (rtrn):
                yield ({(i, j): level[j]})
            else:
                print("[{0}][{1}]".format(i, j))
                pobj(level[j]['data'])
                yield ((i, j))
예제 #10
0
파일: common.py 프로젝트: ihgazni2/nvhead
 def append(self, *args):
     if (args.__len__() == 1):
         if (isinstance(args[0], dict)):
             self.darr.append(args[0])
             self.sarr = type_q_darr2sarr(args[0])
         else:
             self.darr.append({"type": args[0], "q": None})
             self.sarr = type_q_darr2sarr(self.darr)
     else:
         self.darr.append({"type": args[0], "q": str(args[1])})
         self.sarr = type_q_darr2sarr(self.darr)
     pobj(self.sarr)
예제 #11
0
파일: common.py 프로젝트: ihgazni2/nvhead
 def rm_q(self, cond_func):
     indexes = elel.cond_select_indexes_all(self.darr,
                                            cond_func=lambda ele:
                                            (ele['q'] == None))
     idarr = elel.array_map(self.darr, language_locale_q_floatize)
     orig_indexes = elel.cond_select_indexes_all(idarr, cond_func=cond_func)
     idarr = elel.cond_select_values_all(idarr, cond_func=cond_func)
     for index in indexes:
         curr_index = orig_indexes.index(index)
         idarr[curr_index]['q'] = None
     self.darr = idarr
     self.sarr = language_locale_q_darr2sarr(self.darr)
     pobj(self.sarr)
예제 #12
0
 def directives(self, cond):
     if (cond == 'fetch'):
         pobj(self.fetch_directives)
     elif (cond == 'doc'):
         pobj(self.doc_directives)
     elif (cond == 'nav'):
         pobj(self.nav_directives)
     elif (cond == 'report'):
         pobj(self.report_directives)
     elif (cond == 'other'):
         pobj(self.other_directives)
     else:
         pass
예제 #13
0
 def directives(self):
     #kl = ["gzip","compress","deflate","br","identity","*"]
     #vl = ["LZ77","LZW","zlib_deflate","brotli","no compression","no preference"]
     #d = eded.kvlist2d(kl,vl)
     d = {
         'gzip': 'LZ77',
         'compress': 'LZW',
         'deflate': 'zlib_deflate',
         'br': 'brotli',
         'identity': 'no compression',
         '*': 'no preference'
     }
     pobj(d)
예제 #14
0
def srch(s, fn):
    d = {}
    fn = '.' if (fn == '') else fn
    fl = fs.walkf(fn)
    cmdsl = elel.mapv(fl, lambda f: ['cat ' + f, ' egrep "' + s + '"'])
    for i in range(len(cmdsl)):
        cmds = cmdsl[i]
        rslt = pipe_shell_cmds(cmds)
        if (rslt == ""):
            pass
        else:
            cmd = fl[i]
            d[cmd] = rslt
    pobj(d)
    return (d)
예제 #15
0
def init_KPCOFGS(rsltin='path', **kwargs):
    if ('names' in kwargs):
        kpcofgs_names = kwargs['names']
    else:
        kpcofgs_names = [
            'Kingdom', 'Phylum', 'Class', 'Subclass', 'Infraclass', 'Order',
            'Superfamily', 'Family', 'Genus', 'Species'
        ]
    pobj(kpcofgs_names)
    if (rsltin == 'path'):
        rslt = ''
        for i in range(1, kpcofgs_names.__len__()):
            rslt = rslt + '/'
        return (rslt)
    else:
        rslt = {}
        for each in kpcofgs_names:
            rslt[each] = ''
        return (rslt)
예제 #16
0
파일: pobj.py 프로젝트: ihgazni2/ecli
def main():
    pobj(d,
         start=start,
         end=end,
         indent=indent,
         fixed_indent=fixed_indent,
         with_color=with_color,
         key_color=key_color,
         value_color=value_color,
         list_ele_color=list_ele_color,
         op_color=op_color,
         default_color=default_color,
         sp=sp,
         line_sps=line_sps,
         path_sps=path_sps,
         commas=commas,
         colons=colons,
         spaces=spaces,
         quotes_pairs=quotes,
         block_op_pairs=blocks)
예제 #17
0
def get_sortby():
    # sortby = {}
    # eles = root.xpath('//input[@name="sortby"]')
    # for i in range(0,eles.__len__()):
    # ele = eles[i]
    # value = ele.get('value')
    # text = ele.text()
    # sortby[value] = text
    # sortby[text] = value
    # return(sortby)
    sortby = {
        'Species': 'alpha2',
        'Phylogenetic': 'phylo',
        'Extended checklist': 'ext_CL',
        'Show photos': 'ext_pic',
        'Family': 'alpha',
        'Occurrence': 'status'
    }
    pobj(sortby)
    return (sortby)
예제 #18
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)
예제 #19
0
파일: common.py 프로젝트: ihgazni2/nvhead
 def append(self, *args):
     if (args.__len__() == 1):
         if (isinstance(args[0], dict)):
             self.darr.append(args[0])
             self.sarr = type_subtype_q_darr2sarr(args[0])
         elif ("/" in args[0]):
             self.sarr.append(args[0])
             self.darr = type_subtype_q_sarr2darr(self.sarr)
         else:
             print("invalid")
             # self.sarr = type_subtype_q_s2sarr(args[0])
             # self.darr = type_subtype_q_sarr2darr(self.sarr)
     elif (args.__len__() == 2):
         self.darr.append({"type": args[0], "subtype": args[1], "q": None})
         self.sarr = type_subtype_q_darr2sarr(self.darr)
     elif (args.__len__() == 3):
         self.darr.append({
             "type": args[0],
             "subtype": args[1],
             "q": str(args[2])
         })
         self.sarr = type_subtype_q_darr2sarr(self.darr)
     pobj(self.sarr)
예제 #20
0
def main():
    try:
        match = sys.argv[2]
    except:
        pobj(obj)
    else:
        rslt = cmdt[match]
        try:
            seq = int(sys.argv[3])
        except:
            if (isinstance(rslt, tuple)):
                pass
            else:
                pobj(rslt)
        else:
            if (isinstance(rslt, tuple)):
                opts = rslt[1]
                pl = opts[seq][1]
                pobj(dict_getitem_via_path_list(obj, pl))
            else:
                pobj(rslt)
예제 #21
0
 def showall(self, **kwargs):
     if ('mode' in kwargs):
         mode = kwargs['mode']
     else:
         mode = 'readable_path'
     if (mode == 'pathlist'):
         jprint.pobj(self.cmdt.pathlists, fixed_indent=1)
     elif (mode == 'cmdline'):
         jprint.pobj(self.cmdt.cmdlines, fixed_indent=1)
     else:
         readables = {}
         for i in range(0, self.cmdt.pathlists.__len__()):
             readable = hdict_object.path_list_to_console_key_str(
                 self.cmdt.pathlists[i])
             readables[i] = readable
         jprint.pobj(readables, fixed_indent=1)
예제 #22
0
 def __repr__(self):
     if (self.orig == 'object'):
         return (self.object.__repr__())
     elif (self.orig == 'html'):
         return (html)
     elif (self.orig == 'cmdline'):
         jprint.pobj(self.cmdt.pathlists, fixed_indent=1)
         print('\n')
         jprint.pobj(self.cmdt.attribs, fixed_indent=1)
         print('\n')
         jprint.pobj(self.cmdt.results, fixed_indent=1)
         print('\n')
         return (self.cmdt.pathlists.__repr__() +
                 self.cmdt.attribs.__repr__() +
                 self.cmdt.results.__repr__())
     else:
         raise Exception("Invalid INIT!",
                         'not object,not html_text,not cmdline')
예제 #23
0
def shplnd(plnd):
    from xdict.jprint import pobj
    pobj(plnd.jobj)
    wfsmat.shcmmn(plnd.ele)
예제 #24
0
 def lshow_css(self):
     pobj(self.css_cil)
예제 #25
0
 def lshow_content(self):
     pobj(self.content_cil)
예제 #26
0
 def lshow_prelude(self):
     pobj(self.prelude_cil)
예제 #27
0
 def mshow(self, depth=0, width=0):
     pobj(self.mat[depth][width]['data'])
예제 #28
0
 def show(self):
     pobj(self.dict, fixed_indent=True)
예제 #29
0
import collections
import copy
import re
import urllib
import os
import json
import sys

from xdict.jprint import  pobj
from xdict.jprint import  print_j_str
from xdict import cmdline



print("-cpresence options:")
pobj(['present','possible','absent','reported'])

print('----------------------------------------------')

print("-vhabitat options:")
pobj(['Saltwater', 'Commercial', 'Introduced', 'All', 'Reef-associated', 'Dangerous', 'Game fishes', 'Pelagic', 'Endemic', 'Freshwater', 'Threatened', 'Deep-water'])            
pobj(['saltwater', 'commercial', 'introduced', 'alpha2', 'reef', 'dangerous', 'sports', 'pelagic', 'endemic', 'fresh', 'threatened', 'deepwater'])

print('----------------------------------------------')

print("webcrawler usage:")
print('''
    step1: python3 show_country_code.py Mal       (to get country full name)
    step2: python3 show_country_code.py Malaysia  (to get country_code)
    step3: python3 ./WEBCRAWLER/fishbase.us.country.py -country_code 458 -cpresence present -vhabitat saltwater
'''
예제 #30
0
파일: showd.py 프로젝트: ihgazni/NUDILOC
import navegador5.file_toolset as nvft
import os
import json
import sys
from xdict.jprint import pobj

filename = sys.argv[1]
content = nvft.read_file_content(fn=filename, op='r')
d = json.loads(content)
pobj(d)