Ejemplo n.º 1
0
def dict2dir(dir, dic, mode="w"):
    dir = Path(dir)
    if not dir.exists():
        dir.mkdir()
    for filename, content in dic.items():
        p = Path(dir, filename)
        if isinstance(content, dict):
            dict2dir(p, content)
            continue
        f = open(p, mode)
        f.write(content)
        f.close()
Ejemplo n.º 2
0
def dict2dir(dir, dic, mode="w"):
    dir = Path(dir)
    if not dir.exists():
        dir.mkdir()
    for filename, content in dic.items():
        p = Path(dir, filename)
        if isinstance(content, dict):
            dict2dir(p, content)
            continue
        f = open(p, mode)
        f.write(content)
        f.close()
Ejemplo n.º 3
0
 def setup_method(self, method):
     self.d = d = Path(tempfile.mkdtemp())
     dict2dir(d, self.TEST_HIERARCHY)
     self.a_file = Path(d, "a_file")
     self.animals = Path(d, "animals")
     self.images = Path(d, "images")
     self.chef = Path(d, "swedish", "chef", "bork", "bork")
     if hasattr(self.d, "write_link"):
         self.link_to_chef_file = Path(d, "link_to_chef_file")
         self.link_to_chef_file.write_link(self.chef)
         self.link_to_images_dir = Path(d, "link_to_images_dir")
         self.link_to_images_dir.write_link(self.images)
         self.dead_link = self.d.child("dead_link")
         self.dead_link.write_link("nowhere")
     self.missing = Path(d, "MISSING")
     self.d.chdir()
Ejemplo n.º 4
0
 def setup_method(self, method):
     self.d = d = Path(tempfile.mkdtemp())
     dict2dir(d, self.TEST_HIERARCHY)
     self.a_file = Path(d, "a_file")
     self.animals = Path(d, "animals")
     self.images = Path(d, "images")
     self.chef = Path(d, "swedish", "chef", "bork", "bork")
     if hasattr(self.d, "write_link"):
         self.link_to_chef_file = Path(d, "link_to_chef_file")
         self.link_to_chef_file.write_link(self.chef)
         self.link_to_images_dir = Path(d, "link_to_images_dir")
         self.link_to_images_dir.write_link(self.images)
         self.dead_link = self.d.child("dead_link")
         self.dead_link.write_link("nowhere")
     self.missing = Path(d, "MISSING")
     self.d.chdir()