Giter Site home page Giter Site logo

Comments (7)

alan-cugler avatar alan-cugler commented on June 6, 2024

I am adding the following two imports to main.py

import patoolib
from pathlib import Path

I am also adding patool to the requirments.txt file as a dependency.

from modbuddy.

alan-cugler avatar alan-cugler commented on June 6, 2024

I am trying to make this improvement myself, but currently after successfully adding the new mod in with patools, ModBuddy doesnt seem to update its mods list in the json files and therefore refresh the GUI with the new mod row.

from modbuddy.

OlavStornes avatar OlavStornes commented on June 6, 2024

Thanks for the issue. I'm glad to hear that this project is used in a game i'm patiently waiting for further development on.

Regarding patool, i'm noticing that the last release is back in 2016. As long as the package doesn't seem to create any issues with newer versions of python (>=3.9), I'd be thrilled to extend this functionality.

In the example you provided, does the folder actually extracts to the correct place? My suspicion is that patooolib throws FileNoutFoundError, which would prevent calling self.add_mod() in this case (else-clauses in a try-block only fires if there's no handled/unhandled exceptions).

from modbuddy.

alan-cugler avatar alan-cugler commented on June 6, 2024

You are correct about FileNotFoundError, I have reworked the above pseudo code to a working improvement. I just haven't cleaned it up yet to do a PR. After talking with another developer I went with a code solution that remove the try clause and has the target_directory created just before the patoolib extraction.

The main reason i decided this was good enough is because FileNotFoundError shouldn't be the error to populate if the directory is made just before instantiation. There are a other reasons to have a try/except there for the archive extraction, but I wanted to focus on the improvement.

from modbuddy.

alan-cugler avatar alan-cugler commented on June 6, 2024

If you feel like assigning this to me, I expect to have a PR here at some point in the week.

from modbuddy.

OlavStornes avatar OlavStornes commented on June 6, 2024

Glad to hear that. Feel free to provide a solution when ever you have the time, and I'll be happy to look over it.

Regarding removal of the try clause: I'm hesitant to remove that in this case, however it isn't there because of a missing file (judging by your draft which is using FileNotFoundError), but because of potential errors with the archive, such as something unexpected errors regarding the archive itself.
For instance, Shutil.ReadError can occur when an archive is unable to extract for an unspecified reason, such as corrupt data (even though my implementation heavily hints that it is due to an unsupported archive).

from modbuddy.

alan-cugler avatar alan-cugler commented on June 6, 2024

That was my inference. With patoolib taking over for shutil I knew that particular pain should not populate. Though the corrupted archive is a real risk.

from modbuddy.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.