Thu, Apr 18, 6:49 PM CDT

Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Mar 19 1:03 pm)

We now have a ProPack Section in the Poser FreeStuff.
Check out the new Poser Python Wish List thread. If you have an idea for a script, jot it down and maybe someone can write it. If you're looking to write a script, check out this thread for useful suggestions.

Also, check out the official Python site for interpreters, sample code, applications, cool links and debuggers. This is THE central site for Python.

You can now attach text files to your posts to pass around scripts. Just attach the script as a txt file like you would a jpg or gif. Since the forum will use a random name for the file in the link, you should give instructions on what the file name should be and where to install it. Its a good idea to usually put that info right in the script file as well.

Checkout the Renderosity MarketPlace - Your source for digital art content!



Subject: zipfile duplicating files


structure ( ) posted Sat, 02 October 2021 at 10:45 AM · edited Wed, 17 April 2024 at 3:12 AM
Forum Coordinator

my script dynamically creates zipfiles as it needs them and stores them in a list of files. 

The contents are stored in a list of lists, so that the script knows which zip to add them to. 

This part of the script works fine. 

However, after creating the archives, my script needs to append the documentation files to each zip; should be easy enough, but it is not working as expected. 

I have resorted to building a file list before adding the files to the zip. When it reaches the final archive, it adds 2 copies of each file in the folder,  any ideas on how to cure this would be appreciated. 

def add_documentation(self, folder):
docsfolder = file_ops().extend_path(folder, "Documentation")
relative_path = docsfolder
templist = []
    for root, folders, files in os.walk(docsfolder):
for file in files:
file = os.path.join(root
, file)
        if not file.endswith(exclusions) and not file in templist:
templist.append(file)

for builtfile in builtfiles:
with ZipFile(builtfile, "a") as zipf:
if "documentation" in str(docsfolder).casefold():
                        zipf.write(docsfolder, relative_path, zipfile.ZIP_DEFLATED)
                for t in templist:
zipf.write(t)



Locked Out


structure ( ) posted Sun, 03 October 2021 at 3:17 AM · edited Sun, 03 October 2021 at 3:19 AM
Forum Coordinator
So I found a workaround - sloppy but it works
l = len(builtfiles) - 1
if not builtfile == builtfiles[l]:
zipf.write(t)



Locked Out


Privacy Notice

This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.