Exemple #1
0
class Server:
    """ How to use
    1. load() to loading data from the file.
    2. Call getter methods to obtaining and processing a **reference** of loaded data.
    3. save() to saving data to a the file. """

    def __init__(self):
        pass

    def load(self, filepath=None):
        header_lines, task_lines, config_lines, separator = \
            _load_from_anotherfile(filepath)

        self._constcon = _ConstantContent(header_lines, separator)

        self._systemconfig = SystemConfig()
        self._systemconfig.from_lines(config_lines)

        self._alias = Alias()
        self._alias.from_lines(config_lines)

        self._category = Category()
        self._category.from_lines(config_lines)

        self._taskline_container = TaskLineContainer(task_lines, self._systemconfig)

    def save(self, filepath=None):
        task_lines = self._taskline_container.to_lines(no_config=True)

        config_lines = self._systemconfig.to_lines()
        config_lines.extend(self._category.to_lines())
        config_lines.extend(self._alias.to_lines())
        config_lines.sort()

        header_lines = self._constcon.header_lines
        separator = self._constcon.separator

        savee = (header_lines, task_lines, config_lines, separator)
        if filepath:
            _save_to_anotherfile(filepath, *savee)
            return
        _save_to_datafile(*savee)

    def get_systemconfig(self):
        return self._systemconfig

    def get_alias(self):
        return self._alias

    def get_category(self):
        return self._category

    def get_taskline_container(self):
        return self._taskline_container
Exemple #2
0
    def load(self, filepath=None):
        header_lines, task_lines, config_lines, separator = \
            _load_from_anotherfile(filepath)

        self._constcon = _ConstantContent(header_lines, separator)

        self._systemconfig = SystemConfig()
        self._systemconfig.from_lines(config_lines)

        self._alias = Alias()
        self._alias.from_lines(config_lines)

        self._category = Category()
        self._category.from_lines(config_lines)

        self._taskline_container = TaskLineContainer(task_lines, self._systemconfig)