コード例 #1
0
ファイル: clean.py プロジェクト: sparr/fac
    def run(self, args):
        mods = self.manager.find_mods()
        names = sorted([(mod.name, mod.version) for mod in mods])
        to_clean = []
        pointer = (None, None)
        for name in names:
            if name[0] != pointer[0]:
                pointer = name
            else:
                if name[1] < pointer[1]:
                    to_clean += [name]
                else:
                    to_clean += [pointer]
                    pointer = name

        to_clean = [
            self.manager.get_mod(mod[0], version=mod[1]) for mod in to_clean
        ]
        if not to_clean:
            print("No old versions of mods to remove.")
            return
        else:
            print("The following mods will be removed:")
            for mod in to_clean:
                print("    %s" % mod.location)

            if not args.yes and prompt("Continue?", "Y/n") != "y":
                return

            for mod in to_clean:
                mod.remove()
コード例 #2
0
ファイル: remove.py プロジェクト: strawberry-code/fac
    def run(self, args):
        mods = []
        for mod_pattern in args.mods:
            mod_pattern = self.manager.resolve_mod_name(mod_pattern)
            matches = self.manager.find_mods(mod_pattern, packed=args.packed)
            mods.extend(matches)
            if not matches:
                print("No match found for %s." % mod_pattern)

        if mods:
            print("The following mods will be removed:")
            for mod in mods:
                print("    %s" % mod.location)

            if not args.yes and prompt("Continue?", "Y/n") != "y":
                return

            for mod in mods:
                mod.remove()
コード例 #3
0
ファイル: remove.py プロジェクト: mickael9/fac
    def run(self, args):
        mods = []
        for mod_pattern in args.mods:
            mod_pattern = self.manager.resolve_mod_name(mod_pattern)
            matches = self.manager.find_mods(mod_pattern,
                                             packed=args.packed)
            mods.extend(matches)
            if not matches:
                print("No match found for %s." % mod_pattern)

        if mods:
            print("The following mods will be removed:")
            for mod in mods:
                print("    %s" % mod.location)

            if not args.yes and prompt("Continue?", "Y/n") != "y":
                return

            for mod in mods:
                mod.remove()
コード例 #4
0
ファイル: remove.py プロジェクト: Zopieux/fac
    def run(self, args):
        mods = []
        for mod_pattern in args.mods:
            mod_pattern = self.manager.resolve_mod_name(mod_pattern)
            matches = self.manager.find_mods(mod_pattern,
                                             packed=args.packed)
            mods.extend(matches)
            if not matches:
                print('No match found for %s.' % mod_pattern)

        if mods:
            print('The following mods will be removed:')
            for mod in mods:
                print('    %s' % mod.location)

            if not args.yes and prompt('Continue?', 'Y/n') != 'y':
                return

            for mod in mods:
                mod.remove()
コード例 #5
0
ファイル: update.py プロジェクト: Zopieux/fac
    def run(self, args):
        installed = self.manager.find_mods()
        updates = []
        game_ver = self.config.game_version_major

        for local_mod in installed:
            print('Checking: %s' % local_mod.name)
            try:
                remote_mod = self.api.get_mod(local_mod.name)
            except ModNotFoundError as ex:
                print('Warning: %s' % ex)
                continue

            for release in remote_mod.releases:
                if not args.ignore_game_ver and \
                        release.factorio_version != game_ver:
                    continue

                release_ver = Version(release.version)
                local_ver = local_mod.version

                if release_ver > local_ver:
                    print('Found update: %s %s' % (
                        local_mod.name, release.version)
                    )

                    if not args.unpacked and not local_mod.packed:
                        print(
                            '%s is unpacked. '
                            'Use -U to update it anyway.' % (
                                local_mod.name
                            )
                        )
                        continue

                    if not args.held and local_mod.name in self.config.hold:
                        print('%s is held. '
                              'Use -H to update it anyway.' %
                              local_mod.name)
                        break

                    updates.append((local_mod, release))
                    break

        if not updates:
            print('No updates were found')
            return

        print('Found %d update%s:' % (
            len(updates),
            's' if len(updates) != 1 else '',
        ))

        for local_mod, release in updates:
            print('    %s %s -> %s' % (
                local_mod.name, local_mod.version, release.version
            ))

        if not args.show:
            if not args.yes and prompt('Continue?', 'Y/n') != 'y':
                return

            for local_mod, release in updates:
                self.manager.install_mod(release)
コード例 #6
0
ファイル: update.py プロジェクト: sparr/fac
    def run(self, args):
        installed = self.manager.find_mods()
        updates = []

        if args.ignore_game_ver:
            game_ver = None
        else:
            game_ver = self.config.game_version_major

        self.db.update()

        for local_mod in installed:
            print("Checking: %s" % local_mod.name)

            try:
                release = next(
                    self.manager.get_releases(local_mod.name, game_ver))
            except StopIteration:
                continue

            found_update = False
            local_ver = local_mod.version
            latest_ver = local_ver
            latest_release = None

            for release in remote_mod.releases:
                if not args.ignore_game_ver and \
                        parse_game_version(release) != game_ver:
                    continue

                release_ver = Version(release.version)

                if release_ver > latest_ver:
                    found_update = True
                    latest_ver = release_ver
                    latest_release = release

            update_mod = True
            if found_update:
                print("Found update: %s %s" % (local_mod.name, latest_ver))

                if not args.unpacked and not local_mod.packed:
                    print("%s is unpacked. "
                          "Use -U to update it anyway." % (local_mod.name))
                    update_mod = False

                if not args.held and local_mod.name in self.config.hold:
                    print("%s is held. "
                          "Use -H to update it anyway." % local_mod.name)
                    update_mod = False

                if update_mod:
                    updates.append((local_mod, latest_release))

        if not updates:
            print("No updates were found")
            return

        print("Found %d update%s:" % (
            len(updates),
            "s" if len(updates) != 1 else "",
        ))

        for local_mod, release in updates:
            print("    %s %s -> %s" %
                  (local_mod.name, local_mod.version, release.version))

        if not args.show:
            if not args.yes and prompt("Continue?", "Y/n") != "y":
                return

            for local_mod, release in updates:
                self.manager.install_mod(local_mod.name, release)
コード例 #7
0
ファイル: update.py プロジェクト: mickael9/fac
    def run(self, args):
        installed = self.manager.find_mods()
        updates = []

        if args.ignore_game_ver:
            game_ver = None
        else:
            game_ver = self.config.game_version_major

        self.db.update()

        for local_mod in installed:
            print("Checking: %s" % local_mod.name)

            try:
                release = next(self.manager.get_releases(local_mod.name,
                                                         game_ver))
            except StopIteration:
                continue

            release_ver = Version(release.version)
            local_ver = local_mod.version

            if release_ver > local_ver:
                print("Found update: %s %s" % (
                    local_mod.name, release.version)
                )

                if not args.unpacked and not local_mod.packed:
                    print(
                        "%s is unpacked. "
                        "Use -U to update it anyway." % (
                            local_mod.name
                        )
                    )
                    continue

                if not args.held and local_mod.name in self.config.hold:
                    print("%s is held. "
                          "Use -H to update it anyway." %
                          local_mod.name)
                    break

                updates.append((local_mod, release))
                break

        if not updates:
            print("No updates were found")
            return

        print("Found %d update%s:" % (
            len(updates),
            "s" if len(updates) != 1 else "",
        ))

        for local_mod, release in updates:
            print("    %s %s -> %s" % (
                local_mod.name, local_mod.version, release.version
            ))

        if not args.show:
            if not args.yes and prompt("Continue?", "Y/n") != "y":
                return

            for local_mod, release in updates:
                self.manager.install_mod(local_mod.name, release)