Example #1
0
    def main( klas, optz2 =None, args2 =None):
        klas.fix_std_encoding()
        klas._init()
        klas.opts()
        if optz2 or args2:
            options,args = optz.oparser.parse_args( args2 or ())
            if optz2: options._update_loose( optz2)
        else:
            options,args = optz.get()

        for o in optz.iter_opt_defs():
            if o.action != 'append': continue
            k = o.dest
            #uniq
            setattr( options, k,
                listif( p.strip() for p in (getattr( options, k) or ()) ))

        if options.opisi:
            OPISIpat[:] = options.opisi
        global use_stderr
        if options.stderr: use_stderr = True

        info.options = options
        info.args = args
        klas.zaredi_danni( args)
        info.vse_prefix      = commonprefix( [ dirname( i.fname)     for i in info.vse.values() ]) #_real
        info.vse_prefix_orig = commonprefix( [ dirname( i.origfname) for i in info.vse.values() ])

        klas.all()
Example #2
0
def main(info_includes=None, text_excludes=None):
    global optz
    optz, argz = optz.get()
    if optz.io:
        optz.load = optz.save = True
    url = argz and argz[0] or optz.url
    info_includes = textlist(optz.includes_info, info_includes)
    text_excludes = textlist(optz.excludes_name, text_excludes)
    if optz.merge:
        adsnovi = load(optz.merge)
    else:
        adsnovi = url and get(url=url, info_includes=info_includes, text_excludes=text_excludes) or {}
    ads = optz.load and load(optz.fload) or {}
    ads0 = fmtsave(ads)
    for a in ads, adsnovi:
        clean(a, info_includes=info_includes, text_excludes=text_excludes)
    novi = merge(ads, adsnovi)
    if optz.save and (ads0 != fmtsave(ads) or optz.prezapis):
        save(ads, optz.fsave)

    infos = set()
    for a in ads.values():
        infos.update(a.info)
    last = infos and max(info2dati(infos)) or None
    allads = None
    if optz.curprn:
        allads = adsnovi
    if optz.allprn:
        allads = ads
    prn(allads, novi, lastdate=last)
Example #3
0
                q = '&'.join( k+'='+str(v) for k,v in sorted( q.items()))
                t += [ '<a href="query_itemalert?' +q+ '"> inside </a>' ]
            t = '\n<p> '.join( t)
            return t


    from svd_util import optz, eutf
    eutf.fix_std_encoding()
    optz.int( 'port', default= 5000,        help='[%default]' )
    optz.str( 'host', default= 'localhost', help='[%default]' )
    optz.bool( 'load', help= 'load saved data' )
    optz.bool( 'gen',  help= 'make fake data' )
    optz.bool( 'noautogen',  help= 'dont make fake data if nothing loaded' )
    optz.bool( 'save', help= 'save data at end' )
    optz.bool( 'notest', help= 'dont run test before serving' )
    optz,args = optz.get()

    if optz.argus: argus()

    if optz.load: simu.data_load()
    if optz.gen or simu.data_is_empty() and not optz.noautogen: simu.fakedata()
    if not optz.notest: simu.test()

    websimu1.setup()
    try:
        run_simple( optz.host, optz.port, websimu1.app, use_debugger= True, use_reloader= True)
    finally:
        if optz.save: simu.data_save()

# vim:ts=4:sw=4:expandtab
Example #4
0
#!/usr/bin/env python
#$Id: cvs-vim-all.py,v 1.4 2007-12-07 20:46:52 sdobrev Exp $
from __future__ import print_function
from svd_util import gencxx, optz
optz.bool( 'head')
optz,argz = optz.get()

import os.path
#from textwrap import TextWrap
ext_c = '.changed .cpp .cxx .h .hpp .hxx .java'.split()
ext_make = '.mak'.split()

for a in argz:
    org = f = file(a).read()
    if not f.strip(): continue
    ext = os.path.splitext( a )[1].lower()
    is_c = ext in ext_c
    is_make = ext in ext_make or os.path.basename( a ).lower().startswith( 'makef' )

    if optz.head and gencxx._CVShead[:3] not in f:
        h = is_c and gencxx.CVShead or gencxx.CVShead_py
        f = h + f

    if gencxx._VIMtail.strip() not in f:
        h = is_c and gencxx.VIMtail or gencxx.VIMtail_py
        if is_make: h = h.replace( ':expandtab', ':noexpandtab' )
        f = f + h
    if not is_make:
        f = f.expandtabs(4)

    if f != org:
Example #5
0
optz.bool( 'prezapis',      help= 'презаписва всички файлове (иначе само ако са различни)')

optz.text( 'html_enc',      help= 'кодировка на html [%default]', default='utf8', **gg)  #cp1251
optz.text( 'html_spisyk',   help= 'прави общ списък html-страница', **gg)
optz.text( 'html_novi',     help= 'прави списък новости отделен (иначе част от общия списък)', **gg)
optz.text( 'html_izbrani',  help= 'прави списък на само хубавите - извадка от общия списък', **gg)
optz.bool( 'obshto_otgore',         help= 'слага Общо: отгоре (иначе отдолу)', **gg)
optz.bool( 'obshto_broi_zapisi',    help= 'брои файловете със записи, а не папките', **gg)
optz.text( 'podredba',              help= 'подрежда по изброените полета [%default]',
            default= 'humor,ime_sglobeno,pored',
                **gg)
optz.bool( 'otkoga_e_mintime',      help= 'слага липсващо откога=най-ранното време на папката', **gg)
optz.int(  'kolko_dni_e_novo',   default=35, help= 'толкова дни нещо се счита за ново [%default]', **gg)
optz.int(  'kolko_sa_novi',      default=0,  help= 'толкова последни неща се считат за нови [%default]', **gg)

options,args = optz.get()
prikazki.info.options = options

#for path,dirs,files in info.obikoli( args, info.e_za_propuskane ):
data = []
for a in args:
    for f in glob( a+'/*/apapka.tmp'):
        data4papka = DictAttr( eval( open(f).read(), dict( datetime= datetime)))
        data.append( (f, data4papka) )

total = DictAttr(
    time= 0,
    size= 0,
    n= 0,
    n_zapisi = 0,
    )
Example #6
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from svd_util import optz
optz.usage( '%prog [options] < metatoc-script-stdin')
optz.text( 'outpath2opispath', help= 'какво да се добави към outpath за да се стигне до .../opis')
optz.bool( 'opis', help= 'състави опис')
optz.bool( 'toc',  help= 'състави .toc за CDTEXT')
optz.bool( 'cyr2lat',   help= 'ако cd-toc приема само латиница')
opts,args = optz.get()

import sys
import os.path
from svd_util import struct, py3
dictOrder = py3.dictOrder
DictAttr = struct.DictAttr

#allitems = []
#paths = dictOrder()
albumi = dictOrder()

def add( *items, **ka):
    #global allitems
    for i in items:
        i = DictAttr( i)
        #allitems.append( i)
        path = i.path
        opis = os.path.join( path, opts.outpath2opispath or '', 'opis')
        i.opis = opis
        ialbum = i.album or i.title
        try: