예제 #1
0
파일: sloetree.py 프로젝트: sloe/sloe-apps
 def load(self):
     logging.debug("Loading tree %s" % self.spec["name"])
     glb_cfg = SloeConfig.get_global()
     for primacy in glb_cfg.get("global", "primacies").split(","):
         for worth in glb_cfg.get("global", "worths").split(","):
             subdir_path = os.path.join(self.spec["root_dir"], primacy, worth, self.spec["name"])
             logging.debug("Walking path %s" % subdir_path)
             filecount = 0
             bytecount = 0
             for root, dirs, filenames in os.walk(subdir_path):
                 for filename in filenames:
                     match = self.item_ini_regex.match(filename)
                     if match:
                         name = match.group(1)
                         filename_uuid = match.group(2)
                         bytecount += self.add_from_ini(
                             primacy,
                             worth,
                             subdir_path,
                             os.path.relpath(root, subdir_path),
                             filename,
                             name,
                             filename_uuid,
                         )
                         filecount += 1
                     elif self.ini_regex.match(filename):
                         logging.warning("Suspicious misnamed(?) .ini file %s" % os.path.join(root, filename))
             logging.info("Loaded %d item (%d MB) records from %s" % (filecount, bytecount / 2 ** 20, subdir_path))
예제 #2
0
파일: sloetrees.py 프로젝트: sloe/sloe-apps
  def _create_tree(self, tree_name):
    logging.debug("Loading tree %s" % tree_name)

    glb_cfg = SloeConfig.get_global()
    tree_spec = glb_cfg.get_section(glb_cfg.get_tree_key(tree_name))
    tree_spec["name"] = tree_name
    new_tree = SloeTree(tree_spec)
    self.trees[tree_spec["uuid"]] = new_tree
    self.tree_uuids[tree_spec["name"]] = tree_spec["uuid"]
    return new_tree
예제 #3
0
파일: sloetrees.py 프로젝트: sloe/sloe-apps
  def get_treepaths(self, primacy, tree_name):

    glb_cfg = SloeConfig.get_global()
    primacies = glb_cfg.get("global", "primacies").split(",")
    if primacy not in primacies:
      raise sloelib.SloeError("Invalid primacy %s" % primacy)
    root_dir = glb_cfg.get_tree_root_dir(tree_name)
    name = glb_cfg.get(glb_cfg.get_tree_key(tree_name), "name")

    retval = {}

    for worth in glb_cfg.get("global", "worths").split(","):
      retval[worth] = os.path.join(root_dir, primacy, worth, name)
    return retval
예제 #4
0
파일: sloetrees.py 프로젝트: sloe/ws-sloe
 def get_tree_root_dir(self, tree_name):
   glb_cfg = SloeConfig.get_global()
   root_dir = glb_cfg.get(self.get_tree_key(tree_name), "root_dir")
   return root_dir
예제 #5
0
파일: sloeitem.py 프로젝트: sloe/sloe-apps
 def get_file_dir(self):
     root_dir = SloeConfig.get_global().get_tree_root_dir(self._d["tree"])
     return os.path.join(root_dir, self._d["primacy"], self._d["worth"], self._d["tree"], self._d["subtree"])