예제 #1
0
    def _loadChangeLogText(self) -> str:
        # Load change log texts and organize them with a dict
        file_path = Resources.getPath(Resources.Texts, "change_log.txt")
        change_logs_dict = {}  # type: Dict[Version, Dict[str, List[str]]]
        with open(file_path, "r", encoding="utf-8") as f:
            open_version = None  # type: Optional[Version]
            open_header = ""  # Initialise to an empty header in case there is no "*" in the first line of the changelog
            for line in f:
                line = line.replace("\n", "")
                if "[" in line and "]" in line:
                    line = line.replace("[", "")
                    line = line.replace("]", "")
                    open_version = Version(line)
                    if open_version > Version(
                        [14, 99, 99]
                    ):  # Bit of a hack: We released the 15.x.x versions before 2.x
                        open_version = Version([
                            0,
                            open_version.getMinor(),
                            open_version.getRevision(),
                            open_version.getPostfixVersion()
                        ])
                    open_header = ""
                    change_logs_dict[open_version] = collections.OrderedDict()
                elif line.startswith("*"):
                    open_header = line.replace("*", "")
                    change_logs_dict[cast(Version,
                                          open_version)][open_header] = []
                elif line != "":
                    if open_header not in change_logs_dict[cast(
                            Version, open_version)]:
                        change_logs_dict[cast(Version,
                                              open_version)][open_header] = []
                    change_logs_dict[cast(
                        Version, open_version)][open_header].append(line)

        # Format changelog text
        content = ""
        for version in sorted(change_logs_dict.keys(), reverse=True):
            text_version = version
            if version < Version([
                    1, 0, 0
            ]):  # Bit of a hack: We released the 15.x.x versions before 2.x
                text_version = Version([
                    15,
                    version.getMinor(),
                    version.getRevision(),
                    version.getPostfixVersion()
                ])
            content += "<h1>" + str(text_version) + "</h1><br>"
            content += ""
            for change in change_logs_dict[version]:
                if str(change) != "":
                    content += "<b>" + str(change) + "</b><br>"
                for line in change_logs_dict[version][change]:
                    content += str(line) + "<br>"
                content += "<br>"

        return content
예제 #2
0
    def _loadChangeLogText(self) -> str:
        # Load change log texts and organize them with a dict
        try:
            file_path = Resources.getPath(Resources.Texts, "change_log.txt")
        except FileNotFoundError as e:
            # I have no idea how / when this happens, but we're getting crash reports about it.
            return catalog.i18nc("@text:window", "The release notes could not be opened.") + "<br>" + str(e)
        change_logs_dict = {}  # type: Dict[Version, Dict[str, List[str]]]
        try:
            with open(file_path, "r", encoding = "utf-8") as f:
                open_version = None  # type: Optional[Version]
                open_header = ""  # Initialise to an empty header in case there is no "*" in the first line of the changelog
                for line in f:
                    line = line.replace("\n", "")
                    if "[" in line and "]" in line:
                        line = line.replace("[", "")
                        line = line.replace("]", "")
                        open_version = Version(line)
                        if open_version < Version([0, 0, 1]):  # Something went wrong with parsing, assume non-numerical alternate version that should be on top.
                            open_version = Version([99, 99, 99])
                        if Version([14, 99, 99]) < open_version < Version([16, 0, 0]):  # Bit of a hack: We released the 15.x.x versions before 2.x
                            open_version = Version([0, open_version.getMinor(), open_version.getRevision(), open_version.getPostfixVersion()])
                        open_header = ""
                        change_logs_dict[open_version] = collections.OrderedDict()
                    elif line.startswith("*"):
                        open_header = line.replace("*", "")
                        change_logs_dict[cast(Version, open_version)][open_header] = []
                    elif line != "":
                        if open_header not in change_logs_dict[cast(Version, open_version)]:
                            change_logs_dict[cast(Version, open_version)][open_header] = []
                        change_logs_dict[cast(Version, open_version)][open_header].append(line)
        except EnvironmentError as e:
            return catalog.i18nc("@text:window", "The release notes could not be opened.") + "<br>" + str(e)

        # Format changelog text
        content = ""
        for version in sorted(change_logs_dict.keys(), reverse = True):
            text_version = version
            if version < Version([1, 0, 0]):  # Bit of a hack: We released the 15.x.x versions before 2.x
                text_version = Version([15, version.getMinor(), version.getRevision(), version.getPostfixVersion()])
            if version > Version([99, 0, 0]):  # Leave it out altogether if it was originally a non-numbered version.
                text_version = ""
            content += ("<h1>" + str(text_version) + "</h1><br>") if text_version else ""
            content += ""
            for change in change_logs_dict[version]:
                if str(change) != "":
                    content += "<b>" + str(change) + "</b><br>"
                for line in change_logs_dict[version][change]:
                    content += str(line) + "<br>"
                content += "<br>"

        return content
예제 #3
0
    def __initializeStoragePaths(cls):
        Logger.log("d", "Initializing storage paths")
        # use nested structure: <app-name>/<version>/...
        if cls.ApplicationVersion == "master" or cls.ApplicationVersion == "unknown":
            storage_dir_name = os.path.join(cls.ApplicationIdentifier,
                                            cls.ApplicationVersion)
        else:
            from UM.Version import Version
            version = Version(cls.ApplicationVersion)
            storage_dir_name = os.path.join(
                cls.ApplicationIdentifier,
                "%s.%s.%s" % (version.getMajor(), version.getMinor(),
                              version.getRevision()))

        # config is saved in "<CONFIG_ROOT>/<storage_dir_name>"
        cls.__config_storage_path = os.path.join(
            Resources._getConfigStorageRootPath(), storage_dir_name)
        Logger.log("d", "Config storage path is %s", cls.__config_storage_path)

        # data is saved in
        #  - on Linux: "<DATA_ROOT>/<storage_dir_name>"
        #  - on other: "<CONFIG_DIR>" (in the config directory)
        data_root_path = Resources._getDataStorageRootPath()
        cls.__data_storage_path = cls.__config_storage_path if data_root_path is None else \
            os.path.join(data_root_path, storage_dir_name)
        Logger.log("d", "Data storage path is %s", cls.__data_storage_path)
        # cache is saved in
        #  - on Linux:   "<CACHE_DIR>/<storage_dir_name>"
        #  - on Windows: "<CACHE_DIR>/<storage_dir_name>/cache"
        #  - on Mac:     "<CONFIG_DIR>/cache" (in the config directory)
        cache_root_path = Resources._getCacheStorageRootPath()
        if cache_root_path is None:
            cls.__cache_storage_path = os.path.join(cls.__config_storage_path,
                                                    "cache")
        else:
            cls.__cache_storage_path = os.path.join(cache_root_path,
                                                    storage_dir_name)
            if Platform.isWindows():
                cls.__cache_storage_path = os.path.join(
                    cls.__cache_storage_path, "cache")
        Logger.log("d", "Cache storage path is %s", cls.__cache_storage_path)
        # if not os.path.exists(cls.__config_storage_path) or not os.path.exists(cls.__data_storage_path):
        #     cls._copyLatestDirsIfPresent()

        cls.__paths.insert(0, cls.__data_storage_path)
예제 #4
0
    def _loadChangeLogText(self) -> str:
        # Load change log texts and organize them with a dict
        file_path = Resources.getPath(Resources.Texts, "change_log.txt")
        change_logs_dict = {}  # type: Dict[Version, Dict[str, List[str]]]
        with open(file_path, "r", encoding = "utf-8") as f:
            open_version = None  # type: Optional[Version]
            open_header = ""  # Initialise to an empty header in case there is no "*" in the first line of the changelog
            for line in f:
                line = line.replace("\n", "")
                if "[" in line and "]" in line:
                    line = line.replace("[", "")
                    line = line.replace("]", "")
                    open_version = Version(line)
                    if open_version > Version([14, 99, 99]):  # Bit of a hack: We released the 15.x.x versions before 2.x
                        open_version = Version([0, open_version.getMinor(), open_version.getRevision(), open_version.getPostfixVersion()])
                    open_header = ""
                    change_logs_dict[open_version] = collections.OrderedDict()
                elif line.startswith("*"):
                    open_header = line.replace("*", "")
                    change_logs_dict[cast(Version, open_version)][open_header] = []
                elif line != "":
                    if open_header not in change_logs_dict[cast(Version, open_version)]:
                        change_logs_dict[cast(Version, open_version)][open_header] = []
                    change_logs_dict[cast(Version, open_version)][open_header].append(line)

        # Format changelog text
        content = ""
        for version in sorted(change_logs_dict.keys(), reverse = True):
            text_version = version
            if version < Version([1, 0, 0]):  # Bit of a hack: We released the 15.x.x versions before 2.x
                text_version = Version([15, version.getMinor(), version.getRevision(), version.getPostfixVersion()])
            content += "<h1>" + str(text_version) + "</h1><br>"
            content += ""
            for change in change_logs_dict[version]:
                if str(change) != "":
                    content += "<b>" + str(change) + "</b><br>"
                for line in change_logs_dict[version][change]:
                    content += str(line) + "<br>"
                content += "<br>"

        return content
예제 #5
0
def check_version_equals(first_version: Version, second_version: Version):
    assert first_version == second_version
    assert first_version.getMajor() == second_version.getMajor()
    assert first_version.getMinor() == second_version.getMinor()
    assert first_version.getRevision() == second_version.getRevision()
예제 #6
0
def check_version_equals(first_version: Version, second_version: Version):
    assert first_version == second_version
    assert first_version.getMajor() == second_version.getMajor()
    assert first_version.getMinor() == second_version.getMinor()
    assert first_version.getRevision() == second_version.getRevision()