⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sanitycheck.py

📁 this is the most basic to learn python
💻 PY
字号:
#: SanityCheck.py
import string, glob, os
# Do not include the following in the automatic
# tests:
exclude = ("SanityCheck.py", "BoxObserver.py",)

def visitor(arg, dirname, names):
  dir = os.getcwd()
  os.chdir(dirname)
  try:
    pyprogs = [p for p in glob.glob('*.py') 
               if p not in exclude ]
    if not pyprogs: return
    print '[' + os.getcwd() + ']'
    for program in pyprogs:
      print '\t', program
      os.system("python %s > tmp" % program)
      file = open(program).read()
      output = open('tmp').read()
      # Append output if it's not already there:
      if file.find("output = '''") == -1 and \
        len(output) > 0:
        divider = '#' * 50 + '\n'
        file = file.replace('#' + ':~', '#<hr>\n')
        file += "output = '''\n" + \
          open('tmp').read() + "'''\n"
        open(program,'w').write(file)
  finally:
    os.chdir(dir)

if __name__ == "__main__":
  os.path.walk('.', visitor, None)
#:~

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -