예제 #1
0
#!/usr/bin/env python
from __future__ import print_function
import re,sys
from svd_util import eutf
enc = eutf.e_utf_stdout() and 'utf-8' or 'cp1251'
r = sys.argv.pop(1).decode( enc)
#print r, sys.argv
rx = re.compile( r)
for f in sys.argv[1:]:
    for a in eutf.readlines( file(f)):
        if rx.search( a): print( f,':',a)
예제 #2
0
        if cond:
            tt = re.sub( '\$\d', '.*', target )
            yield '''
RewriteCond %%{REQUEST_URI} !^%(tt)s'''.strip() % locals()
        yield rule1( target, pfxs+lat)
    if cyr:
        yield ' '.join( ['#', cyr, pfxs] + encs)
        for e in encs:
            rcyr = cyr_is_reg and cyr or reg( cyr, enc=e)#, do_optz_partial =False)
            yield rule1( target, pfxs+rcyr)
    yield ''

if __name__ == '__main__':
    import sys
    try: spc = sys.argv.remove( '--spc') or ' '
    except: spc=''

    from svd_util import eutf
    eutf.fix_std_encoding()
    for a in sys.argv[1:]:
        a = a.decode( eutf.e_utf_stdout() and 'utf8' or 'cp1251')
        #print a
        for enc in ('utf8', 'cp1251'):
            print( enc, a)
            print( reg( a, enc, spc))

#rules-usage
#for a in rule( '/detski/lego',   'lego',     'лего',     pfxs= ['', 'detski'] ): print a

# vim:ts=4:sw=4:expandtab
예제 #3
0
    def zaredi_danni( klas, args):
        ''' - прочита всички описи
            - при преводи, обикаля всички директории и запомня кои имат преводи
              - тези от тях които нямат описи, им се правят нови
            - за всички описи
              - ако нямат име, се слага от преводи ако има
              - самопопълва звук/година от името-на-директорията
              - добавя поисканите етикети
        '''
        options = klas.options

        #################
        #зареждане на данни, заявки, и пр. - четене/оправяне на ОПИСИте

        if options.prevodi:
            if options.podrobno: prn( 'prevodi:', options.prevodi)
            for k,(v,o) in prevodi_file2ime( eutf.readlines( options.prevodi)):
                klas._nov_prevod( fname= k, ime= zaglavie(v), original= zaglavie(o), roditel= options.prevodi)
                if options.podrobno: prn( '%-40s = %s' % (k,v) )

        if options.prevodi_meta:
            info.meta_prevodi.update( meta_prevodi( options.prevodi_meta, dict= dict_lower,
                        prn= options.podrobno and prn, zaglavie= 'мета-преводи', razdelitel_v_nachaloto=True
                        ))

        info.fenc = options.filename_enc or (eutf.e_utf_stdout() and 'utf-8' or locale.getpreferredencoding())
        if options.podrobno:
            prn( 'filename_enc:', info.fenc)
            prn( 'stdout.enc:', sys.stdout.encoding, sys.stdout)
            prn( 'stderr.enc:', sys.stderr.encoding, sys.stderr)

        etiketi = {}
        for e in options.etiket or ():
            klas.procheti_etiket( e, etiketi)

        options.dirs = []
        za_pravene = {}
        for path,dirs,files in klas.obikoli( args, klas.e_za_propuskane ):
            if options.prevodi:
                for dname in dirs:
                    pname = join( path, dname)
                    if not options.simvolni and os.path.islink( pname): continue
                    p = klas.vse_prevodi.get( dname)
                    if p:
                        rpname = realpath( pname)
                        za_pravene[ rpname] = p.ime, pname

            pname = realpath( path)
            for fname in files:
                if not e_opis( fname): continue
                i = klas( pname, redove= join( path, fname), origfname= path)
                if options.podrobno: prn( i.fname)
                if options.podrobno>1: prn( i.dump() )

        for path,dirs,files in klas.obikoli( options.papka_s_opisi or () ):
            pname = realpath( path)
            for fname in files:
                if klas.e_za_propuskane( fname): continue
                i = klas( join( pname, fname), redove= join( path, fname), origfname= join( path, fname), isdir=False)
                if options.podrobno: prn( i.fname)

        for pname,(ime,fpath) in za_pravene.items():
            if pname not in info.vse:
                i = klas( pname)
                i.slaga_ime( ime)

        for k,i in sorted( info.vse.items()):
            try:
                i.samopopylva_ot_fname()
                fname = basename( i.fname)
                p = klas.vse_prevodi.get( fname)
                if p:
                    if not i.imeto or options.popravi_opisi:
                        i.slaga_ime( p.ime)
                    if p.original and not i.etiketi.original:
                        i.slaga_etiket( i.stoinosti.original, p.original )

                i.etiketi.update_pre( **etiketi)
                i.samopopylva_etiketi()
                razlika, t = i.zapis( naistina= options.zapis_opisi )
                #if razlika: print '-----------'
            except:
                print( '????', fname)
                raise