MCPcopy Index your code
hub / github.com/indigo-dc/udocker / _load_structure

Method _load_structure

udocker/docker.py:706–740  ·  view source on GitHub ↗

Load the structure of a Docker image

(self, tmp_imagedir)

Source from the content-addressed store, hash-verified

704 CommonLocalFileApi.__init__(self, localrepo)
705
706 def _load_structure(self, tmp_imagedir):
707 """Load the structure of a Docker image"""
708 structure = {}
709 structure["repolayers"] = {}
710 structure["repoconfigs"] = {}
711 for fname in os.listdir(tmp_imagedir):
712 f_path = tmp_imagedir + '/' + fname
713 if fname == "repositories":
714 structure["repositories"] = \
715 self.localrepo.load_json(f_path)
716 elif fname == "manifest.json":
717 structure["manifest"] = \
718 self.localrepo.load_json(f_path)
719 elif fname.endswith(".json") and FileUtil(f_path).isfile():
720 structure["repoconfigs"][fname] = {}
721 structure["repoconfigs"][fname]["json"] = self.localrepo.load_json(f_path)
722 structure["repoconfigs"][fname]["json_f"] = f_path
723 elif FileUtil(f_path).isdir():
724 layer_id = fname
725 structure["repolayers"][layer_id] = {}
726 for layer_f in os.listdir(f_path):
727 layer_f_path = f_path + '/' + layer_f
728 if layer_f == "VERSION":
729 structure["repolayers"][layer_id]["VERSION"] = \
730 self.localrepo.load_json(layer_f_path)
731 elif layer_f == "json":
732 structure["repolayers"][layer_id]["json"] = \
733 self.localrepo.load_json(layer_f_path)
734 structure["repolayers"][layer_id]["json_f"] = layer_f_path
735 elif "layer" in layer_f:
736 structure["repolayers"][layer_id]["layer_f"] = layer_f_path
737 else:
738 Msg().out("Info: warning: unknown file in layer:",
739 f_path, l=Msg.WAR)
740 return structure
741
742 def _find_top_layer_id(self, structure, my_layer_id=""):
743 """Find the top layer within a Docker image"""

Callers 2

loadMethod · 0.95

Calls 6

FileUtilClass · 0.90
MsgClass · 0.90
load_jsonMethod · 0.80
isfileMethod · 0.80
isdirMethod · 0.80
outMethod · 0.80

Tested by 1