Пример #1
0
Файл: blog.py Проект: Peiiii/wk
 def do_route(req_path):
     print('reqpath:',req_path)
     root_path=self.db.get('root_path')
     print("root_path:",root_path)
     real_path=root_path+'/'+req_path if req_path!='' else root_path
     real_path=PowerDirPath(real_path)
     print("real_path:",real_path)
     basename=real_path.basename()
     if basename.startswith('view='):
         real_path=real_path.dirname()/basename[len('view='):]
         print("real_path:",real_path)
         if real_path.isdir():
             return self.do_view_dir(real_path)
         else:
             return self.do_view_file(real_path)
     else:
         if real_path.isdir():
             return self.do_send_dir(real_path)
         elif real_path.isfile():
             return self.do_send_file(real_path)
     return 'not finished.'
Пример #2
0
def rarx(src=None, dst=None):
    from wpkit.basic import PowerDirPath
    import os
    src = src or './'
    src = PowerDirPath(src)
    if src.isdir():
        dst = dst or src
        dst = PowerDirPath(dst)
        fs = src.glob('*.rar')
        for i, f in enumerate(fs):
            dn = f.basename()[:-4]
            dp = dst.join_path(dn)
            unrar(f, dp)
            print(i, f, dp)
    elif src.isfile():
        assert src.endswith('.rar')
        dst = dst or src[:-4]
        unrar(src, dst)
        print(src, dst)
    print('finished.')