Example #1
0
 def loadPAC(self):
     searchdir = QtCore.QDir.currentPath()
     """alterdir = os.path.join(adapter.getHome(), ".local", "share", "Steam", "SteamApps", "common")
     if os.path.isdir(alterdir):
         searchdir = alterdir"""
     fName = QtGui.QFileDialog.getOpenFileName(self,
                                               "Load PAC file",
                                               searchdir,
                                               self.tr("All Files (*);;PAC Files (*.pac)"))
     if fName != "":
         self.staging = fileadding_utils.staging()
         try:
             self.statusText.setText("Loading %s" % self.staging.target)
             self.staging.loadPackage(fName)
         except FileNotFoundError as e:
             self.errorbox(str(e))
         self.updatePACScreen()
         self.statusText.setText("Ready")
Example #2
0
 def newPAC(self):
     self.staging = fileadding_utils.staging()
     self.updateStagingScreen()
     self.statusText.setText("Ready")
def cliUI(cmdline):
    sekai = fileadding_utils.staging()
    docompress = not cmdline.no_compress
    dryrun = cmdline.dry_run
    # staging operations
    if cmdline.stage:
        if cmdline.add:
            if os.path.isfile(cmdline.file):
                if os.path.isdir(cmdline.base_dir):
                    relpath = os.path.relpath(cmdline.file, cmdline.base_dir)
                    newbie = sekai.addfile(relpath, cmdline.file, compression=docompress)
                    if newbie:
                        print("Added new file with name: " + datastruct.adjustSeparatorForPac(relpath))
                    else:
                        print("File " + datastruct.adjustSeparatorForPac(relpath) + " will be replaced")
                else:
                    print("directory \"" + cmdline.add + "\" si not valid")
            elif os.path.isdir(cmdline.file):
                sekai.addDirectory(cmdline.file, compression=docompress, verbose=True, wholedir=True)
            else:
                print("file \"" + cmdline.file + "\" not found")
            sekai.saveEnviron()
        elif cmdline.merge:
            if os.path.isdir(cmdline.file):
                sekai.addDirectory(cmdline.file, compression=docompress, verbose=True, wholedir=False)
            else:
                print("directory \"" + cmdline.add + "\" si not valid")
            sekai.saveEnviron()
        elif cmdline.undo:
            undid = sekai.undoFile(cmdline.file)
            if not undid:
                print("Warning: command had no effect (typo in filename?)")
            sekai.saveEnviron()
        elif cmdline.remove:
            removed = sekai.removeFile(cmdline.file)
            if not removed:
                print("Warning: command had no effect (typo in filename?)")
            sekai.saveEnviron()
        elif cmdline.commit:
            sekai.commit()
            print("Commit completed")
            sekai.saveEnviron()
        elif cmdline.write:
            sekai.writeout(cmdline.file, dry_run=dryrun, debuggy=cmdline.debug)
            if not dryrun:
                sekai.clearEnviron()
        elif cmdline.peek:
            nonStaging(sekai.package, cmdline, sekai.target)
        elif cmdline.list:
            sekai.listInfo()
        elif cmdline.list_harder:
            sekai.listDetailed()

        # other operations

        elif cmdline.file: # targeting (initialize staging)
            sekai.loadPackage(cmdline.file)
            print("Staging environment initialized with target pacfile: " + sekai.target)
            sekai.saveEnviron()

        else:
            sekai.start_id = cmdline.offset
            sekai.saveEnviron()

    # non-staging operations
    elif cmdline.file is not None:
        pac = datastruct.pacfile()
        with open(cmdline.file, "rb") as binfile:
            pac.loadFromFile(binfile)
        nonStaging(pac, cmdline, cmdline.file)

    else:
        if cmdline.version:
            print(info.getInfoMsg())
def cliUI(cmdline):
    sekai = fileadding_utils.staging()
    docompress = not cmdline.no_compress
    dryrun = cmdline.dry_run
    # staging operations
    if cmdline.stage:
        if cmdline.add:
            if os.path.isfile(cmdline.file):
                if os.path.isdir(cmdline.base_dir):
                    relpath = os.path.relpath(cmdline.file, cmdline.base_dir)
                    newbie = sekai.addfile(relpath, cmdline.file, compression=docompress)
                    if newbie:
                        print("Added new file with name: " + datastruct.adjustSeparatorForPac(relpath))
                    else:
                        print("File " + datastruct.adjustSeparatorForPac(relpath) + " will be replaced")
                else:
                    print('directory "' + cmdline.add + '" si not valid')
            elif os.path.isdir(cmdline.file):
                sekai.addDirectory(cmdline.file, compression=docompress, verbose=True, wholedir=True)
            else:
                print('file "' + cmdline.file + '" not found')
            sekai.saveEnviron()
        elif cmdline.merge:
            if os.path.isdir(cmdline.file):
                sekai.addDirectory(cmdline.file, compression=docompress, verbose=True, wholedir=False)
            else:
                print('directory "' + cmdline.add + '" si not valid')
            sekai.saveEnviron()
        elif cmdline.undo:
            undid = sekai.undoFile(cmdline.file)
            if not undid:
                print("Warning: command had no effect (typo in filename?)")
            sekai.saveEnviron()
        elif cmdline.remove:
            removed = sekai.removeFile(cmdline.file)
            if not removed:
                print("Warning: command had no effect (typo in filename?)")
            sekai.saveEnviron()
        elif cmdline.commit:
            sekai.commit()
            print("Commit completed")
            sekai.saveEnviron()
        elif cmdline.write:
            sekai.writeout(cmdline.file, dry_run=dryrun, debuggy=cmdline.debug)
            if not dryrun:
                sekai.clearEnviron()
        elif cmdline.peek:
            nonStaging(sekai.package, cmdline, sekai.target)
        elif cmdline.list:
            sekai.listInfo()
        elif cmdline.list_harder:
            sekai.listDetailed()

        # other operations

        elif cmdline.file:  # targeting (initialize staging)
            sekai.loadPackage(cmdline.file)
            print("Staging environment initialized with target pacfile: " + sekai.target)
            sekai.saveEnviron()

        else:
            sekai.start_id = cmdline.offset
            sekai.saveEnviron()

    # non-staging operations
    elif cmdline.file is not None:
        pac = datastruct.pacfile()
        with open(cmdline.file, "rb") as binfile:
            pac.loadFromFile(binfile)
        nonStaging(pac, cmdline, cmdline.file)

    else:
        if cmdline.version:
            print(info.getInfoMsg())