Exemple #1
0
 def default_to_system_db(self, location, name):
     file = os.path.join(
         self.layout_dir(location, pyyjj.layout.SQLITE),
         "{}.{}".format(name, pyyjj.get_layout_name(pyyjj.layout.SQLITE)))
     if os.path.exists(file):
         return file
     else:
         system_location = pyyjj.location(pyyjj.mode.LIVE,
                                          pyyjj.category.SYSTEM, "etc",
                                          "kungfu", self)
         system_file = os.path.join(
             self.layout_dir(system_location, pyyjj.layout.SQLITE),
             "{}.{}".format(name,
                            pyyjj.get_layout_name(pyyjj.layout.SQLITE)))
         shutil.copy(system_file, file)
         return file
Exemple #2
0
 def layout_dir(self, location, layout):
     mode = pyyjj.get_mode_name(location.mode)
     category = pyyjj.get_category_name(location.category)
     p = os.path.join(self._home, category, location.group, location.name, pyyjj.get_layout_name(layout), mode)
     if not os.path.exists(p):
         os.makedirs(p)
     return p
Exemple #3
0
 def layout_dir(self, location, layout):
     mode = pyyjj.get_mode_name(location.mode)
     category = pyyjj.get_category_name(location.category)
     p = os.path.join(self._home, category, location.group, location.name,
                      pyyjj.get_layout_name(layout), mode)
     try:
         os.makedirs(p)
     except OSError as e:
         if e.errno != errno.EEXIST:
             raise
     return p
Exemple #4
0
 def layout_file(self, location, layout, name):
     return os.path.join(
         self.layout_dir(location, layout),
         "{}.{}".format(name, pyyjj.get_layout_name(layout)))