コード例 #1
0
ファイル: hf.py プロジェクト: svilendobrev/svd_bin
Хвост Феи == Gekijouban Fairy Tail

S\d{1,2}E\d+
''')


if __name__ == '__main__':

    srcs = dict( (d.__name__, d) for d in Iztochnik.__subclasses__())

    from svd_util import optz
    optz.text( 'ienc',          help= 'входно кодиране; подразбиране - автоматично' )
    optz.text( 'oenc',          help= 'изходно кодиране', )
    optz.int(  'stranici',      help= 'колко страници; подразбиране - според източника', default=0 )
    optz.list( 'iztochnik',
        type= 'choice', choices= sorted( srcs),
        help= 'източник (%s), може няколко пъти; подразбиране - всички' % ' '.join( sorted( srcs)) )
    optz.text( 'skriti',    help= 'файл с филтрите')
    optz.bool( 'podrobno',  help= 'показва извлечените имена')
    optz.bool( 'trij',      help= 'изтрива филтрираните елементи вместо само да ги скрива/свива')
    optz,argz = optz.get()

    if optz.ienc=='auto': optz.ienc=None

    if optz.oenc:
        from svd_util.eutf import fix_std_encoding, filew
        fix_std_encoding( ENC= optz.oenc)
    def fopen( fn):
        if optz.oenc: f = filew( optz.oenc, fn)
        else: f = open( fn, 'w')
        return f
コード例 #2
0
ファイル: symlinker.py プロジェクト: svilendobrev/svd_bin
from os.path import isdir, basename, exists, join, dirname, realpath
from svd_util import optz, osextra

optz.help( '''
walklink sourceitem[s] target  -  mv/cp/ln that sees through dir+file symlinks
    if targetnotexists
        TODO if one source, rename it
        else - make targetdir, move sources into it
    if target.exists
        if target.isdir, move sources into it
        TODO elif target.isfile and one source.isfile and --force, overwrite target
        else error: multiple or non-file sources into existing target.file
''')

optz.bool( 'force', '-f', help= 'force source file to overwrite target file if exists')
optz.list( 'exclude',    help= 'exclude filepattern (multiple)')
optz.list( 'include',    help= 'include filepattern (multiple)')
optz.list( 'direxclude', help= 'exclude dirpattern  (multiple)')
optz.list( 'dirinclude', help= 'include dirpattern  (multiple)')
optz.bool( 'verbose', '-v')
optz.simvolni = True #',  '-L', help= 'обхожда и символни връзки')

ops = {
    os.rename : 'mv move',
    os.link   : 'ln link',
#   os.link   : 'cp copy',
    None:       'print',
}
op2op = {}
for op,names in ops.items():
    for n in names.split():
コード例 #3
0
ファイル: symlinker.py プロジェクト: svilendobrev/jbase
optz.help(
    """
walklink sourceitem[s] target  -  mv/cp/ln that sees through dir+file symlinks
    if targetnotexists
        TODO if one source, rename it
        else - make targetdir, move sources into it
    if target.exists
        if target.isdir, move sources into it
        TODO elif target.isfile and one source.isfile and --force, overwrite target
        else error: multiple or non-file sources into existing target.file
"""
)

optz.bool("force", "-f", help="force source file to overwrite target file if exists")
optz.list("exclude", help="exclude filepattern (multiple)")
optz.list("include", help="include filepattern (multiple)")
optz.list("direxclude", help="exclude dirpattern  (multiple)")
optz.list("dirinclude", help="include dirpattern  (multiple)")
optz.simvolni = True  #',  '-L', help= 'обхожда и символни връзки')

ops = {
    os.rename: "mv move",
    os.link: "ln link",
    #   os.link   : 'cp copy',
    None: "print",
}
op2op = {}
for op, names in ops.items():
    for n in names.split():
        op2op[n] = op
コード例 #4
0
ファイル: pozvanete.py プロジェクト: svilendobrev/svd_bin
    # remove hanging open <
    d = re.sub(b"<([^>]*?<)", rb"\1", d)
    # if d!=d1: print( 2222222)

    if ienc:
        d = d.decode(ienc)
    return d


from svd_util.struct import DictAttr
from svd_util import optz

optz.text("url", default="http://pozvanete.bg/imoti-prodava-offline&maxAds=100?page={npage}")
optz.int("pages", default=11)
optz.list("includes_info")
optz.list("excludes_name")
optz.bool("load")
optz.bool("save")
optz.bool("cache")
optz.bool("io", help="load+save")
optz.text("fload", default="danni.pozv", help="[%default]")
optz.text("fsave", default="danni.pozv", help="[%default]")
optz.bool("allprn", help="покажи всички въобще, а не само новите")
optz.bool("curprn", help="покажи всички сега-прочетени, а не само новите")
optz.text("merge", help="смеси тези данни")
optz.bool("podrobno", "-v", help="видимост!")
optz.bool("prezapis", help="презаписва дори и да няма нужда")
optz.bool("debug", help="само гледа входа")

コード例 #5
0
ファイル: renit.py プロジェクト: svilendobrev/svd_bin
#!/usr/bin/env python3
# -*- coding: utf8 -*-
from svd_util import optz
optz.usage( '%prog [optz] ot-dir < ren-script-stdin')
#optz.optany( 'ot')
optz.text(  'link_kym',  help= 'направи ново дърво от връзки с този корен')
optz.bool( 'rename',     help= 'преименувай на място')
optz.bool( 'rename_alt', help= 'преименувай на място и остави символна връзка към старото име.alt')
optz.list( 'opis', help= 'подменя имена в опис ; може няколко пъти')
optz.bool( 'link_zagolemi_pootdelno', help= 'връзки: раздели заголеми/ на /moze /neizv ..')
optz.bool( 'nothing', '-n')
oparser = optz.oparser
optz,args = optz.get()

import os, sys, stat
from os.path import join, exists, dirname, basename, splitext

allfiles = {}
def link( ot, ikym, *pfxs):
    print( ot, ikym)
    ot = join( dir_ot, ot)
    assert exists( ot)
    if not optz.link_zagolemi_pootdelno and sum('zagolemi' in p for p in pfxs):
        pfxs = ['zagolemi']
    for pfx in pfxs:
        kym = join( optz.link_kym, pfx, ikym)
        ss = list( os.stat( ot) )   ## dict( size= ss[ stat.ST_SIZE], ..
        for ix in stat.ST_CTIME, stat.ST_NLINK:
            ss[ix] = None
        if kym in allfiles:
            old = allfiles[kym]
コード例 #6
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function

import os
join = os.path.join

from svd_util import optz
optz.help( 'apply moves-around-dirs/deletes from template/ into .')
optz.bool( 'real', '-y', )
optz.text( 'exclude', '-x', help= 'regexp',)
optz.list( 'ignore' , '-i', help= 'file/dir-names', default= [])
optz.bool( 'alsodirs' , help= 'check moving of dirs too')
optz.bool( 'dup2ignore' , help= 'ignore duplicates')
optz.text( 'deldir' , default='del', help= 'folder to move deleted items into [%default]')
optz,args = optz.get()
none = not optz.real

template = args[0].rstrip('/')

from collections import defaultdict
tree = {}
paths = set()

try: os.mkdir( 'del')
except Exception as e: print( e)

#optz.exclude = [ a.rstrip('/') for a in optz.exclude ]
exclude = None
if optz.exclude:
    import re