Unmantained Guida [PYTHON-RELEASE] Script cambia estensioni {richiede Python installato sul proprio PC...}

Una guida contrassegnata come Unmantained contiene informazioni su un argomento obsoleto, non più utile o files non aggiornati da parte del creatore.
Stato
Discussione chiusa ad ulteriori risposte.
Ultima modifica:
Re: [PYTHON**RELEASE] Script cambia estensioni {richiede Python installato sul proprio PC...}

[11:10:44] :): Puoi postare

as requested
******

Codice:
import os
class Metin2_Pack_Extension:
    def PrintFile(self, text):
        f=open("logs.txt", "a")
        f.write("%s\n" % text)
        f.close()
    def Check_Directory(self):
        Check=[0, 0, 0, 0, 0, 0, 0]
        for i in os.listdir(os.getcwd()):
            if i == "artpclnt.dll":
                Check[0]=1
            elif i == "devil.dll":
                Check[1]=1
            elif i == "msvcp60.dll":
                Check[2]=1
            elif i == "MSS32.DLL" or i == "mss32.dll":
                Check[3]=1
            elif i == "SpeedTreeRT.dll":
                Check[4]=1
            elif i == "python22.dll":
                Check[5]=1
            elif i == "granny2.dll":
                Check[6]=1
        if Check[0]==1 and Check[1]==1 and Check[2]==1 and Check[3]==1 and Check[4]==1 and Check[5]==1 and Check[6]==1:
            return 1
        else:
            return 0
    def Main(self):
        print "\nCambio Estensioni ** By Revolution\n"
        print "All rights reserved 2013**2014."
        epk_o=raw_input("Old EPK Extension **> .")
        eix_o=raw_input("Old EIX Extension **> .")
        epk=raw_input("New EPK Extension **> .")
        eix=raw_input("New EIX Extension **> .")
        epack_directory="pack"
        if len(epk_o)==3 and len(eix_o) and len(epk)==3 and len(eix)==3 and epk_o != epk and eix_o != eix and epk != eix and epk_o != eix_o:
            if self.Check_Directory() == 0:
                print "Controllo Directory Fallito...\n<< Posiziona il file sulla cartella principale del client >>"
                self.Main()
            print "Controllo Directory OK..."
            print "Controllo Estensioni OK..."
            files=[]
            for i in os.listdir(epack_directory):
                if i.endswith(".%s" % epk_o) or i.endswith(".%s" % eix_o):
                    files.append(i)
            if len(files) > 0:
                for i in files:
                    if i.endswith(".%s" % epk_o):
                        newfile=i.replace(".%s" % epk_o, ".%s" % epk)
                        self.PrintFile("[EPK] Changing extension of %s in %s..." % (i, newfile))
                        os.rename("%s/%s" % (epack_directory, i), "%s/%s" % (epack_directory, newfile))
                        self.PrintFile("[EPK] Extension of %s changed in %s successfully!" % (i, newfile))
                    elif i.endswith(".%s" % eix_o):
                        newfile=i.replace(".%s" % eix_o, ".%s" % eix)
                        self.PrintFile("[EIX] Changing extension of %s in %s" % (i, newfile))
                        os.rename("%s/%s" % (epack_directory, i), "%s/%s" % (epack_directory, newfile))
                        self.PrintFile("[EIX] Extension of %s changed in %s successfully!" % (i, newfile))
                print "All of extensions are changed."
            else:
                print "E**Pack files not found."
            exit=raw_input("Press [ENTER]")
            self.Main()
        else:
            print "Le estensioni devono:\n1) Avere 3 caratteri.\n2) Non devono essere uguali."
            self.Main()
    def __init__(self):
        self.Main()
Metin2_Pack_Extension()

Se avete qualche versione arcaica di python sul pc e per qualche motivo strano non vi fungesse endswith:

Codice:
def endswith(self, str, needle):
	if (needle.__class__.__name__ == "list"):
		for i in needle:
			if (str[**len(i) : ] == i):
				return 1
		return 0
 
Ultima modifica:
Re: [PYTHON**RELEASE] Script cambia estensioni {richiede Python installato sul proprio PC...}

as requested
******

Codice:
            if i == "artpclnt.dll":
                Check[0]=1
            elif i == "devil.dll":
                Check[1]=1
            elif i == "msvcp60.dll":
                Check[2]=1
            elif i == "MSS32.DLL" or i == "mss32.dll":
                Check[3]=1
            elif i == "SpeedTreeRT.dll":
                Check[4]=1
            elif i == "python22.dll":
                Check[5]=1
            elif i == "granny2.dll":
                Check[6]=1
        if Check[0]==1 and Check[1]==1 and Check[2]==1 and Check[3]==1 and Check[4]==1 and Check[5]==1 and Check[6]==1:
            return 1
        else:
            return 0
Troppo brutto come codice
Codice:
#schifo:
if Check[0]==1 and Check[1]==1 and Check[2]==1 and Check[3]==1 and Check[4]==1 and Check[5]==1 and Check[6]==1:
            return 1
        else:
            return 0
#better way:
return (1 in Check)
Codice:
#schifo:
            if i == "artpclnt.dll":
                Check[0]=1
            elif i == "devil.dll":
                Check[1]=1
            elif i == "msvcp60.dll":
                Check[2]=1
            elif i == "MSS32.DLL" or i == "mss32.dll":
                Check[3]=1
            elif i == "SpeedTreeRT.dll":
                Check[4]=1
            elif i == "python22.dll":
                Check[5]=1
            elif i == "granny2.dll":
                Check[6]=1
#better way:
tuplatime=("artpclnt.dll","devil.dll","msvcp60.dll","mss32.dll","speedtreert.dll","python22.dll","granny2.dll")
for idx1 in range(len(tuplatime)):
    if(i.lower()==tuplatime[idx1]):
        Check[idx1]=1
Ma, ancora meglio ancora: (se ho tempo, dopo accorcio ancora di più le righe)
Codice:
    def Check_Directory(self):
        tuplatime=("artpclnt.dll","devil.dll","msvcp60.dll","mss32.dll","speedtreert.dll","python22.dll","granny2.dll")
        ret=0
        for i in os.listdir(os.getcwd()):
            if(i.lower() in tuplatime): ret=1 #e qua metterci anche un break
        return ret
La sintassi che sto proponendo è tutta presente nel python2.2 stesso (quindi immaginatevi cosa si potrebbe fare con un py2.7 o py3.x installato sul pc)
È possibile riassumere tutto in una sola riga (for, if e return in uno)
 
Re: [PYTHON**RELEASE] Script cambia estensioni {richiede Python installato sul proprio PC...}

Troppo brutto come codice
Codice:
#schifo:
if Check[0]==1 and Check[1]==1 and Check[2]==1 and Check[3]==1 and Check[4]==1 and Check[5]==1 and Check[6]==1:
            return 1
        else:
            return 0
#better way:
return (1 in Check)
Codice:
#schifo:
            if i == "artpclnt.dll":
                Check[0]=1
            elif i == "devil.dll":
                Check[1]=1
            elif i == "msvcp60.dll":
                Check[2]=1
            elif i == "MSS32.DLL" or i == "mss32.dll":
                Check[3]=1
            elif i == "SpeedTreeRT.dll":
                Check[4]=1
            elif i == "python22.dll":
                Check[5]=1
            elif i == "granny2.dll":
                Check[6]=1
#better way:
tuplatime=("artpclnt.dll","devil.dll","msvcp60.dll","mss32.dll","speedtreert.dll","python22.dll","granny2.dll")
for idx1 in range(len(tuplatime)):
    if(i.lower()==tuplatime[idx1]):
        Check[idx1]=1
Ma, ancora meglio ancora: (se ho tempo, dopo accorcio ancora di più le righe)
Codice:
    def Check_Directory(self):
        tuplatime=("artpclnt.dll","devil.dll","msvcp60.dll","mss32.dll","speedtreert.dll","python22.dll","granny2.dll")
        ret=0
        for i in os.listdir(os.getcwd()):
            if(i.lower() in tuplatime): ret=1 #e qua metterci anche un break
        return ret

il codice non è mio xD, avrei usato glob e splittato per risparmiarmi la creazione manuale dell' array.
 
Re: [PYTHON**RELEASE] Script cambia estensioni {richiede Python installato sul proprio PC...}

Ma per modificare le estensioni non basta fare un file .bat con dentro:

ren *.eix *.estensione
ren *.epk *.estensione
 
Quindi mettiamo che un client ha le estensioni cambiate, tipo invece di .epk ha .xyz... Con questo tool posso, cambiarle in .epk, decryptarle e inserire un hack, recompilarle e metterle di nuovo in .xyz? :)
 
Se son solo cambiate le estensioni si :asd:
Ma comunque come detto sopra, bastava un bat con:

Codice:
@echo off
ren *.eix *.<nuovaext>
ren *.epk *.<nuovaext>

senza interpreti e cagate varie!
 
Stato
Discussione chiusa ad ulteriori risposte.
Indietro
Top Bottom