示例#1
0
文件: piu.py 项目: Peiiii/wpkit
 def __init__(self, path):
     self.seta(path=path)
     path = PowerDirPath(self.geta('path'))
     if path.exists():
         assert path.isfile()
         dic = json_load(path)
         assert isinstance(dic, dict)
     else:
         dic = {}
         path.tofile()
         json_dump(dic, path, indent=4)
     super().__init__(dic)
示例#2
0
文件: rar.py 项目: Peiiii/wpkit
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.')
示例#3
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.'