Exemplo n.º 1
0
class SettingLoader(object):
    """load the image setting from json files"""
    def __init__(self, in_file):
        self.__json_loader = JsonLoader(in_file)
        self.group_name = os.path.basename(in_file[:in_file.rfind('.')])
        self.__option = None
        self.__size = None
        self.__global_rank = None
        self.images = {}
        self.load_setting()

    def load_setting(self):
        self.__option = self.__json_loader.get_root_obj(OPTION_KEY)
        self.__size = self.__json_loader.get_root_obj(SIZE_KEY)
        self.__global_rank = self.__json_loader.get_root_obj(RANK_KEY)
        root = self.__json_loader.get_root_obj("image")
        if not root:
            return
        assert isinstance(root, dict)
        for pattern in root:
            obj = Image.create(pattern, root[pattern], self.group_name,
                               self.__option, self.__size, self.__global_rank)
            if obj:
                self.images[pattern] = obj

    def print(self):
        print("group name:", self.group_name)
        print("option:", self.__option)
        print("size:", self.__size)
        print("global rank:", self.__global_rank)
        for pattern in self.images:
            self.images[pattern].print()
Exemplo n.º 2
0
class SettingLoader(object):
    """load the image setting from json files"""

    def __init__(self, in_file):
        self.__json_loader = JsonLoader(in_file)
        self.group_name = os.path.basename(in_file[:in_file.rfind('.')])
        self.__option = None
        self.__size = None
        self.__global_rank = None
        self.images = {}
        self.load_setting()

    def load_setting(self):
        self.__option = self.__json_loader.get_root_obj("option")
        self.__size = self.__json_loader.get_root_obj("size")
        self.__global_rank = self.__json_loader.get_root_obj("rank")
        root = self.__json_loader.get_root_obj("image")
        if not root:
            return
        assert isinstance(root, dict)
        for pattern in root:
            self.images[pattern] = Image.create(pattern, root[pattern], self.group_name, self.__option, self.__size,
                                                self.__global_rank)

    def print(self):
        print("group name:", self.group_name)
        print("option:", self.__option)
        print("size:", self.__size)
        print("global rank:", self.__global_rank)
        for pattern in self.images:
            self.images[pattern].print()
Exemplo n.º 3
0
 def __init__(self, in_file):
     self.__json_loader = JsonLoader(in_file)
     self.group_name = os.path.basename(in_file[:in_file.rfind('.')])
     self.__option = None
     self.__size = None
     self.__global_rank = None
     self.images = {}
     self.load_setting()
Exemplo n.º 4
0
 def __init__(self, in_file):
     self.__json_loader = JsonLoader(in_file)
     self.group_name = os.path.basename(in_file[:in_file.rfind('.')])
     self.__option = None
     self.__size = None
     self.__global_rank = None
     self.images = {}
     self.load_setting()
Exemplo n.º 5
0
class SettingLoader(object):
    """load the phrase setting from json files"""

    def __init__(self, in_file):
        self.__json_loader = JsonLoader(in_file)
        self.__global_rank = None
        self.phrases = {}
        self.load_setting()

    def load_setting(self):
        self.__global_rank = self.__json_loader.get_root_obj("rank")
        root = self.__json_loader.get_root_obj("phrase")
        if not root:
            return
        assert isinstance(root, dict)
        for phrase_group_name in root:
            self.phrases[phrase_group_name] = PhraseGroup.create(
                phrase_group_name, root[phrase_group_name], self.__global_rank
            )

    def print(self):
        for phrase_group_name in self.phrases:
            self.phrases[phrase_group_name].print()
Exemplo n.º 6
0
 def __init__(self, in_file):
     self.__json_loader = JsonLoader(in_file)
     self.__global_rank = None
     self.phrases = {}
     self.load_setting()