Пример #1
0
def exercise_cleanup():
    from libtbx.path import clean_out_directory
    from six.moves import cStringIO as StringIO
    import shutil
    import os
    if os.path.isdir("tmp_libtbx_path_cleanup"):
        shutil.rmtree("tmp_libtbx_path_cleanup")
    os.mkdir("tmp_libtbx_path_cleanup")
    os.chdir("tmp_libtbx_path_cleanup")
    os.makedirs("AutoSol_run_1_/TEMP0")
    os.makedirs("AutoBuild_run_2_/TEMP0")
    os.makedirs("AutoBuild_run_2_/resolve_1.ccp4")
    with open("AutoBuild_run_2_/TEMP0/model.pdb", "w") as f:
        f.write("END\n")
    os.makedirs("Refine_3/.comm")
    with open("Refine_3/refine_3.geo", "w") as f:
        f.write("\n")
    with open("Refine_3/refine_3.kin", "w") as f:
        f.write("\n")
    with open("Refine_3/refine_3_2fofc.ccp4", "w") as f:
        f.write("\n")
    with open("Refine_3/refine_3_fofc.xplor", "w") as f:
        f.write("\n")
    with open("probe.txt", "w") as f:
        f.write("\n")
    os.mkdir("FFT_4")
    with open("FFT_4/refine_3_2fofc.ccp4", "w") as f:
        f.write("\n")
    c_o_d = clean_out_directory(".")
    out = StringIO()
    c_o_d.show(out=out)
    assert (out.getvalue() == """\
The following 3 directories will deleted:
  ./AutoBuild_run_2_/TEMP0
  ./AutoSol_run_1_/TEMP0
  ./Refine_3/.comm
The following 5 files will be deleted:
  ./Refine_3/refine_3.geo
  ./Refine_3/refine_3.kin
  ./Refine_3/refine_3_2fofc.ccp4
  ./Refine_3/refine_3_fofc.xplor
  ./probe.txt
0.0 KB of disk space will be freed.
"""), out.getvalue()
Пример #2
0
def exercise_cleanup () :
  from libtbx.path import clean_out_directory
  from cStringIO import StringIO
  import shutil
  import os
  if os.path.isdir("tmp_libtbx_path_cleanup") :
    shutil.rmtree("tmp_libtbx_path_cleanup")
  os.mkdir("tmp_libtbx_path_cleanup")
  os.chdir("tmp_libtbx_path_cleanup")
  os.makedirs("AutoSol_run_1_/TEMP0")
  os.makedirs("AutoBuild_run_2_/TEMP0")
  os.makedirs("AutoBuild_run_2_/resolve_1.ccp4")
  open("AutoBuild_run_2_/TEMP0/model.pdb", "w").write("END\n")
  os.makedirs("Refine_3/.comm")
  open("Refine_3/refine_3.geo", "w").write("\n")
  open("Refine_3/refine_3.kin", "w").write("\n")
  open("Refine_3/refine_3_2fofc.ccp4", "w").write("\n")
  open("Refine_3/refine_3_fofc.xplor", "w").write("\n")
  open("probe.txt", "w").write("\n")
  os.mkdir("FFT_4")
  open("FFT_4/refine_3_2fofc.ccp4", "w").write("\n")
  c_o_d = clean_out_directory(".")
  out = StringIO()
  c_o_d.show(out=out)
  assert (out.getvalue() == """\
The following 3 directories will deleted:
  ./AutoBuild_run_2_/TEMP0
  ./AutoSol_run_1_/TEMP0
  ./Refine_3/.comm
The following 5 files will be deleted:
  ./Refine_3/refine_3.geo
  ./Refine_3/refine_3.kin
  ./Refine_3/refine_3_2fofc.ccp4
  ./Refine_3/refine_3_fofc.xplor
  ./probe.txt
0.0 KB of disk space will be freed.
"""), out.getvalue()