Problem while trying to extract a directory from a zipfile.
vincent wehren
vincent at visualtrans.de
Wed Dec 8 12:04:01 EST 2004
More information about the Python-list mailing list
Wed Dec 8 12:04:01 EST 2004
- Previous message (by thread): updating locals() and globals() (WAS: How do I do this? (eval() on the left hand side))
- Next message (by thread): Problem while trying to extract a directory from a zipfile.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
ralobao wrote:
> I have this code:
>
> try:
> file = zipfile.ZipFile(nome_arquivo)
> Gauge.start() #inicia o Gauge
> for element in file.namelist():
> try:
> newFile = open(diretorio + element,"wb")
> except:
> newFile = open(diretorio + element + '/',"w")
> # Gauge
> percent = percent + 10
> Gauge.update(percent)
> Gauge.set_text("Extraindo" + element)
> # Extrai
> newFile.write(file.read(element))
> newFile.close()
>
> But when i try to extract an zipfile with a directory in it the code
> returns me an IOErro exception: "It is a directory"
>
> Please how can i solve it ?
You need to create any directories yourself. Maybe
the recipe at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252508
gives you some ideas on how.
HTH
--
Vincent Wehren
- Previous message (by thread): updating locals() and globals() (WAS: How do I do this? (eval() on the left hand side))
- Next message (by thread): Problem while trying to extract a directory from a zipfile.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list