Giter VIP home page Giter VIP logo

Comments (4)

sbraz avatar sbraz commented on May 25, 2024

Well we don't really need libmediainfo in order to parse the XML files it created…
Theoretically, I may want to load an XML file created on another computer although I don't have the lib installed locally.

from pymediainfo.

madebr avatar madebr commented on May 25, 2024

How about a can_parse member class function of the MediaInfo class? (or something similar)
What I want is a way to check whether parsing works before doing any actual parsing.

Something like this:

class MediaInfo(object):
    @classmethod
    def _get_library(cls):
        if os.name in ("nt", "dos", "os2", "ce"):
            return windll.MediaInfo
        elif sys.platform == "darwin":
            try:
                return CDLL("libmediainfo.0.dylib")
            except OSError:
                return CDLL("libmediainfo.dylib")
        else:
            return CDLL("libmediainfo.so.0")

    @classmethod
    def can_parse(cls):
        try:
            cls._get_library()
            return True
        except:
            return False

from pymediainfo.

sbraz avatar sbraz commented on May 25, 2024

That sounds reasonable, yeah. I'm not too experienced with staticmethod/classmethod, any reason why you chose the latter?

from pymediainfo.

madebr avatar madebr commented on May 25, 2024

I chose classmethod where the method needs information about the class.
Staticmethod where it does nog.
So _get_library is ok with staticmethod (different from my code),
the can_parse has some connection with MediaInfo.

It's a matter of choice. The code would also work with 2 staticmethods.

from pymediainfo.

Related Issues (20)

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.