乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      增加自動(dòng)創(chuàng)建插件工程的Python腳本

       dinghj 2014-05-01

      為了避免手工創(chuàng)建新的插件工程,同時(shí)也是學(xué)習(xí)python,今天用了6個(gè)小時(shí)邊學(xué)邊試,終于編寫(xiě)完了。

      學(xué)習(xí)到的新知識(shí)有:

      1、正則表達(dá)式一次替換多種子串
      2、遍歷創(chuàng)建目錄
      3、回調(diào)函數(shù)
      4、路徑模塊
      5、字典的一些用法
      6、主函數(shù)、編寫(xiě)習(xí)慣、遞進(jìn)開(kāi)發(fā)方式

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      42
      43
      44
      45
      46
      47
      48
      49
      50
      51
      52
      53
      54
      55
      56
      57
      58
      59
      60
      61
      62
      63
      64
      65
      66
      67
      68
      69
      70
      71
      72
      73
      74
      75
      76
      77
      78
      79
      80
      81
      82
      83
      84
      85
      86
      87
      88
      89
      90
      91
      92
      93
      94
      95
      96
      97
      98
      #!/usr/bin/env python
      """
      Function:   Create a plugin project based on Win32DllTempl or MFCExtTempl.
                  This script has been tested with ActivePython 2.7.
      Usage:      makeplugin.py projname pkgname basetype
                  projname: name of the new project.
                  pkgname: package name of the new project, the default value
                      is 'pkg_Example'.
                  basetype: 'mfc', 'win32', 'view' or project name in pkg_Example,
                      the default value is 'win32'.
      Creator:    ooyg <rhcad@hotmail.com>
      Date:       2011.10.9
      ChangeList:
          1. Implemented the function: multireplace, copyfiles, makeproj
          2. Add 'view' for the param of 'basetype'.
             Skip project files while copying files in pkg_Example. [2011/10/10]
      """
      import os, sys, re
      def multireplace(text, adict):
          rx = re.compile('|'.join(map(re.escape, adict)))
          def xlat(match):
              return adict[match.group(0)]
          return rx.sub(xlat, text)
      def copyfiles(srcdir, destdir, pairs, callback=None):
          if srcdir.find(".svn") > 0:
              return
          if not os.path.exists(destdir):
              os.makedirs(destdir)
           
          for fn in os.listdir(srcdir):
              srcfile = os.path.join(srcdir, fn)
              destfile = os.path.join(destdir, multireplace(fn, pairs))
               
              if os.path.isdir(srcfile):
                  copyfiles(srcfile, destfile, pairs)
              if os.path.isfile(srcfile) and not os.path.exists(destfile) \
                      and (not callback or callback(fn, pairs)):
                  open(destfile, "wb").write(open(srcfile, "rb").read())
                  text = open(destfile).read()
                  newtext = multireplace(text, pairs)
                  if newtext != text:
                      open(destfile, 'w').write(newtext)
                      print('%s [replaced]' % destfile)
                  else:
                      print(destfile)
      def makeproj(projname, pkgname, baseproj):
          codepath = os.path.abspath('../code')
          basepath = os.path.join(codepath, 'pkg_Example', 'Modules', baseproj)
           
          if not os.path.exists(basepath):
              raise OSError, basepath
          if not os.path.exists(os.path.join(codepath, pkgname)):
              raise OSError, os.path.join(codepath, pkgname)
          if projname == '':
              raise AttributeError, projname
          destdir = os.path.join(codepath, pkgname, 'Modules', projname)
          pairs = {baseproj:projname, 'pkg_Example':pkgname}
           
          def matchfile(filename, pairs):
              if filename.find(".dsp") > 0 or filename.find(".vc") > 0:
                  return False
              return True
          copyfiles(basepath, destdir, pairs, matchfile)
          def matchproj(filename, pairs):
              for key in pairs.keys():
                  if filename.startswith(key):
                      return True
              return False
          projects = os.path.abspath('../projects/msvc/vcproj')
          copyfiles(projects, projects, pairs, matchproj)
      if __name__=="__main__":
          def inputparam(index, prompt, default=''):
              if len(sys.argv) > index:
                  ret = sys.argv[index]
              else:
                  ret = raw_input(prompt)
              if ret == '': ret = default
              return ret
           
          projname = inputparam(1, 'Project name: ')
          pkgname  = inputparam(2, 'Package name (pkg_Example): ', 'pkg_Example')
          baseproj = inputparam(3, 'Template project (win32, mfc, view, '   \
                                   'or project name in pkg_Example): ', 'win32')
                       
          if baseproj == 'win32': baseproj = 'Win32DllTempl'
          if baseproj == 'mfc':   baseproj = 'MFCExtTempl'
          if baseproj == 'view':  baseproj = 'HelloView'
           
          makeproj(projname, pkgname, baseproj)

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶(hù) 評(píng)論公約

        類(lèi)似文章 更多