示例#1
0
 def setUp(self):
     self.collection = RafCollection(os.path.join(
         TEST_ROOT,
         "data",
     ))
     self.tmp_dir = os.path.join(TEST_ROOT, 'tmp')
     mkdir_p(self.tmp_dir)
示例#2
0
 def build_fake_archive(self, version, content):
     version_dir = os.path.join(self.tmp_dir, "0.0.0.{}".format(version))
     mkdir_p(version_dir)
     fakeArchive = BaseRafArchive(os.path.join(version_dir, 'Archive.raf'))
     fakefile = RafFile(fakeArchive)
     fakefile.path = "DATA/Trolls/Are/funny.txt"
     fakefile.insert(content)
     fakeArchive.addRafFile(fakefile)
     fakeArchive.save()
示例#3
0
 def build_fake_archive(self, version, content):
     version_dir = os.path.join(self.tmp_dir, "0.0.0.{}".format(version))
     mkdir_p(version_dir)
     fakeArchive = BaseRafArchive(os.path.join(version_dir, 'Archive.raf'))
     fakefile = RafFile(fakeArchive)
     fakefile.path = "DATA/Trolls/Are/funny.txt"
     fakefile.insert(content)
     fakeArchive.addRafFile(fakefile)
     fakeArchive.save()
示例#4
0
    def discard_backup(self):
        try:
            if (os.path.exists(self.backup_dir)):
                shutil.rmtree(self.backup_dir)
            mkdir_p(self.backup_dir)
        except Exception:
            return self.cancel_with_error(
                "Unable to delete backup folder dir! Check permissions.")

        self.notification.set("Backup destroyed!")
        self.explanation['bg'] = 'green'

        self.update_buttons()

        root.update()
示例#5
0
 def setUp(self):
     self.collection = RafCollection(os.path.join(TEST_ROOT, "data", ))
     self.tmp_dir = os.path.join(TEST_ROOT, 'tmp')
     mkdir_p(self.tmp_dir)
示例#6
0
 def setUp(self):
     self.tmp_dir = os.path.join(TEST_ROOT, 'tmp')
     self.archive = RafArchive(os.path.join(TEST_ROOT, "data", 'filearchives', '0.0.0.0', "Archive_194801136.raf"))
     mkdir_p(self.tmp_dir)
示例#7
0
 def setUp(self):
     self.tmp_dir = os.path.join(TEST_ROOT, 'tmp')
     mkdir_p(self.tmp_dir)
示例#8
0
文件: rafiki.py 项目: tnajdek/rafiki
    collection = ri.get_raf_collection()
except Exception:
    print("Unable to find filearchives in \"%s\", are you sure this is valid path to Leauge of Legends?" % args.source_path)
    sys.exit()


if(args.filter):
    files = collection.search(args.filter)
else:
    files = collection.raffiles()

if(args.action == 'extract'):
    for raf_file in files:
        data = raf_file.extract()
        raf_file_path = convert_lol_path(raf_file.path)
        mkdir_p(basepath + os.sep + os.path.dirname(raf_file_path))
        with open(basepath + os.sep + raf_file_path, 'wb') as target_file:
            target_file.write(data)

if(args.action == 'pack'):
    archives = set()
    for raf_file in files:
        raf_file_path = convert_lol_path(raf_file.path)
        file_path = os.path.join(args.override, raf_file_path)
        try:
            with open(file_path, 'rb') as f:
                raf_file.insert(f.read())
            print("Using override for %s in %s" % (raf_file.path, raf_file.archive.path))
        except IOError:
            pass
        archives.add(raf_file.archive)
示例#9
0
    def process(self):
        try:
            target_resolution = int(self.userInput['resolution'].get())
        except Exception:
            return self.cancel_with_error(
                "Resolution {} seems incorrect".format(target_resolution))

        if (target_resolution < 1):
            return self.cancel_with_error(
                "Resolution {} seems incorrect".format(target_resolution))

        self.discard_backup()
        self.processButton.pack_forget()

        try:
            mkdir_p(self.backup_dir)
        except Exception:
            return self.cancel_with_error(
                "Unable to create backup folder dir! Check permissions.")

        self.notification.set("Parsing raf files...")
        self.explanation['bg'] = 'green'
        root.update()

        try:
            self.ri.installation_path = self.userInput['lol_folder'].get()
            self.rm = self.ri.get_raf_manifest()
            collection = self.ri.get_raf_collection()
            raffiles = collection.search(self.userInput['raf_path'].get())
        except Exception:
            return self.cancel_with_error(
                "Unable to find raf collections. Check your Leagues of Legends path and try again."
            )

        # decide which raffile is from the most recent archive
        max_version_seen = 0
        for raffile in raffiles:
            if (raffile.archive.lol_version > max_version_seen):
                latest_raffile = raffile

        raffile = latest_raffile
        archive = raffile.archive
        actual_path = self.rm.find(raffile.path)[0]

        #backup relevant archive
        self.notification.set("Creating backups...")
        self.explanation['bg'] = 'green'
        root.update()

        # backup archive
        target_path = os.path.join(self.backup_dir, 'filearchives',
                                   archive.relpath)
        mkdir_p(os.path.dirname(target_path))
        shutil.copyfile(archive.path, target_path)
        shutil.copyfile("{}.dat".format(archive.path),
                        "{}.dat".format(target_path))

        rlsmanifest_target_path = os.path.join(self.backup_dir, 'releases',
                                               self.rm.lol_version,
                                               'releasemanifest')
        mkdir_p(os.path.dirname(rlsmanifest_target_path))
        shutil.copyfile(self.rm.path, rlsmanifest_target_path)

        self.notification.set("Calculating new positions...")
        self.explanation['bg'] = 'green'

        # extract data
        rafdata_input = raffile.extract()

        # sanity check
        assert self.rm.file_tree[actual_path]['size'] == len(raffile.data)
        assert self.rm.file_tree[actual_path]['md5'] == hashlib.md5(
            raffile.data).digest()
        assert self.rm.file_tree[actual_path]['compressed_size'] == len(
            raffile.raw_data)

        # calc new position
        ui = Clarity.from_binary(rafdata_input)
        counter = 0
        for name, item in ui.elements.items():
            # print("{}: {}".format(name, item.anchor.x))
            if (item.anchor.x == 1.0 or item.anchor.x == 0.0):
                item.position = reanchor_centrally(item, target_resolution)
                item.anchor = Vec2(0.5, item.anchor.y)
                counter += 1

        # store new raffile contents
        rafdata_output = ui.to_binary()
        raffile.insert(rafdata_output)

        # update the manifest
        self.rm.file_tree[actual_path]['size'] = len(raffile.data)
        self.rm.file_tree[actual_path]['compressed_size'] = len(
            raffile.raw_data)
        self.rm.file_tree[actual_path]['md5'] = hashlib.md5(
            raffile.data).digest()

        self.notification.set("Saving updated archive...")
        self.explanation['bg'] = 'green'

        archive.save()
        self.rm.save()

        self.notification.set(
            "Done! Repositioned {} elements of the UI. Hope it worked, enjoy!".
            format(counter))
        self.explanation['bg'] = 'green'

        self.update_buttons()
示例#10
0
except Exception:
    print(
        "Unable to find filearchives in \"%s\", are you sure this is valid path to Leauge of Legends?"
        % args.source_path)
    sys.exit()

if (args.filter):
    files = collection.search(args.filter)
else:
    files = collection.raffiles()

if (args.action == 'extract'):
    for raf_file in files:
        data = raf_file.extract()
        raf_file_path = convert_lol_path(raf_file.path)
        mkdir_p(basepath + os.sep + os.path.dirname(raf_file_path))
        with open(basepath + os.sep + raf_file_path, 'wb') as target_file:
            target_file.write(data)

if (args.action == 'pack'):
    archives = set()
    for raf_file in files:
        raf_file_path = convert_lol_path(raf_file.path)
        file_path = os.path.join(args.override, raf_file_path)
        try:
            with open(file_path, 'rb') as f:
                raf_file.insert(f.read())
            print("Using override for %s in %s" %
                  (raf_file.path, raf_file.archive.path))
        except IOError:
            pass
示例#11
0
 def setUp(self):
     self.tmp_dir = os.path.join(TEST_ROOT, 'tmp')
     mkdir_p(self.tmp_dir)
示例#12
0
 def setUp(self):
     self.tmp_dir = os.path.join(TEST_ROOT, 'tmp')
     self.archive = RafArchive(
         os.path.join(TEST_ROOT, "data", 'filearchives', '0.0.0.0',
                      "Archive_194801136.raf"))
     mkdir_p(self.tmp_dir)