• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 319, comments - 22, trackbacks - 0, articles - 11
              C++博客 :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理
              1 #!/usr/bin/env python
              2 # -*- coding: utf-8 -*-
              3 
              4 
              5 # Fast copy for Winodws or Linux
              6 # Copy file to
              7 
              8 import os
              9 import sys
             10 import re
             11 from optparse import OptionParser
             12 
             13 
             14 def CallFastCmd(src, dest):
             15      cmd = "XCOPY " + src +" " + dest
             16      print u"命令行"+ cmd
             17      os.system(cmd)
             18 
             19 def SplitStr(src, split):
             20      return src.split(split)
             21 
             22 
             23 
             24 def IsCanCopy(path, include, exclude):
             25     IsCan = False
             26     split = "|"
             27     if include is None:
             28         if exclude is None:
             29             IsCan = True
             30         else:
             31             for excStr in SplitStr(exclude, split):
             32                if (excStr not in path):
             33                    IsCan = True
             34     else:
             35         for incStr in SplitStr(include, split):
             36 
             37              if exclude is not None :
             38                  for excStr in SplitStr(exclude, split):
             39                      if (excStr not in path) and (incStr in path):
             40                          IsCan = True
             41              elif incStr in path:
             42                  IsCan = True
             43 
             44 
             45 
             46     #返回值
             47     return IsCan
             48 
             49 
             50 
             51 def CopyToSubDir(src, des, include, exclude, regEnable):
             52     for root,dirs,files in os.walk(des):
             53         for dirPath in dirs:
             54             subPath = os.path.join(root,dirPath) # 路徑
             55             if not regEnable:
             56                if IsCanCopy(subPath, include, exclude):
             57                    CallFastCmd(src, subPath)
             58             else#使用正則表達(dá)式
             59                 incReg = include
             60                 excReg = exclude
             61 
             62                 incMatch = incReg.match(incReg, subPath)
             63                 if incMatch is not None:
             64                     excMatch = excReg.match(excReg, subPath)
             65                     if excMatch is None:
             66                         CallFastCmd(src, subPath)
             67 
             68 
             69 
             70 
             71 
             72 def Copy(src, des, include, exclude , regEnable):
             73     if not os.path.exists(des):
             74         CallFastCmd(src, des)
             75     else:
             76         CopyToSubDir(src, des, include, exclude, regEnable)
             77 
             78 
             79 
             80 def ParseCmd():
             81     parser = OptionParser()
             82     parser.add_option("-s""--src", action="store", dest="src", help="input the Dir or file")
             83     parser.add_option("-d""--des", action="store", dest="des", help="input the Dir or file")
             84     parser.add_option("-i""--include",action="store", dest="include", help="input the include string")
             85     parser.add_option("-e""--exclude",action="store", dest="exclude", help="input the exclude string")
             86     parser.add_option("-r""--regEnable",action="store_true", dest="regEnable", default=False, help="input the exclude string")
             87 
             88 
             89     (options, args) = parser.parse_args()
             90     if options.src is None:
             91         parser.error("The source is none")
             92     if options.des is None:
             93         parser.error("The dest is none")
             94 
             95     Copy(options.src, options.des, options.include, options.exclude, options.regEnable)
             96 
             97 if __name__ == "__main__":
             98     ParseCmd()
             99 
            100 
            无码八A片人妻少妇久久| 色综合久久久久无码专区| 久久99精品久久久久久噜噜| 欧美久久久久久精选9999| 久久久无码精品亚洲日韩蜜臀浪潮| 婷婷综合久久中文字幕蜜桃三电影| 四虎国产精品免费久久5151| 99久久这里只精品国产免费| 久久Av无码精品人妻系列| 久久久久国色AV免费看图片| 久久99精品久久久久子伦| 精品久久久久成人码免费动漫| 久久99国产精品99久久| 亚洲欧美日韩中文久久| 伊人情人综合成人久久网小说| 久久精品国产91久久综合麻豆自制 | 亚洲va国产va天堂va久久| 精品国产乱码久久久久久浪潮| 粉嫩小泬无遮挡久久久久久| 无码任你躁久久久久久老妇App| 久久99热这里只有精品国产| 成人免费网站久久久| 人妻无码中文久久久久专区| 欧美亚洲国产精品久久久久| 久久精品国产欧美日韩| 国产成人精品综合久久久| 久久青草国产手机看片福利盒子| 久久久久久无码Av成人影院| 久久九九精品99国产精品| 少妇久久久久久久久久| 色综合久久久久综合体桃花网| 伊人久久综合无码成人网| 亚洲va久久久噜噜噜久久天堂| 久久亚洲sm情趣捆绑调教| 成人午夜精品无码区久久| 亚洲va久久久噜噜噜久久狠狠| 麻豆成人久久精品二区三区免费| 色8久久人人97超碰香蕉987| 精品免费久久久久久久| 99久久亚洲综合精品网站| 久久久久人妻精品一区三寸蜜桃|