Git Product home page Git Product logo

Comments (14)

ryanlong1004 avatar ryanlong1004 commented on July 18, 2024

@demberto the only place Parser is instantiated is in conftest.py.

Refactoring from static class methods to module methods with satisfy the ticket.

https://stackoverflow.com/questions/31875/is-there-a-simple-elegant-way-to-define-singletons

from pyflp.

demberto avatar demberto commented on July 18, 2024

@ryanlong1004 What about static class counts? _FLObject._count? _FLObject._ppq? How would you manage two sets of static variables, for example at the same time?

from pyflp.

ryanlong1004 avatar ryanlong1004 commented on July 18, 2024

I don't think those are necessary.

  • Mostly, self is being used to call other class methods.
  • You should never have to 'reset' static variables. They should either be class methods to count instances or don't need to exist.
  • All of the __private methods indicate (IMHO) they should be module methods that can, if needed, be called via an exposed class method.
  • All of the self.__parse_xyz(ev), those should be props and ev should be a prop of that class.

EDIT: I know saying things like "never" are hyperbole, but they are code smells.

from pyflp.

ryanlong1004 avatar ryanlong1004 commented on July 18, 2024

"""Reset static variables. This allows multiple instances of Parser
in a single instance of the interpreter. HOWEVER THIS DOESN'T WORK FOR
USING MULTIPLE INSTANCES AT THE SAME TIME."""

Use instances if you need to.

from pyflp.

demberto avatar demberto commented on July 18, 2024

For a long amount of time I always thought of how I should structure the parser. I feel count is useless anyways. Your __parse_xyz idea is good but how do I implement it?

from pyflp.

ryanlong1004 avatar ryanlong1004 commented on July 18, 2024

Can I do a little refactoring and submit a PR for you to look at?

from pyflp.

demberto avatar demberto commented on July 18, 2024

Sure, sure 🀝

from pyflp.

demberto avatar demberto commented on July 18, 2024

@ryanlong1004 any updates?

from pyflp.

ryanlong1004 avatar ryanlong1004 commented on July 18, 2024

@demberto I did some work a week or so back. Let me see if I can get a PR over.

from pyflp.

ryanlong1004 avatar ryanlong1004 commented on July 18, 2024

I'm bowing out. 😎

from pyflp.

demberto avatar demberto commented on July 18, 2024

Bruh.

from pyflp.

ryanlong1004 avatar ryanlong1004 commented on July 18, 2024
@staticmethod
    def __reset_static_vars() -> None:
        #TODO Get rid of
        """Reset static variables. This allows multiple instances of `Parser`
        in a single instance of the interpreter. HOWEVER THIS DOESN'T WORK FOR
        USING MULTIPLE INSTANCES AT THE SAME TIME."""

        _FLObject._count = 0 #TODO get rid of eventually
        _Event._count = 0 #TODO get rid of eventually
        for subclass in _FLObject.__subclasses__():
            subclass._count = 0

Parser manipulates Events and the FLV(?) by directly changing each's class attributes to keep track. Then there's a reset method that also acts directly on those class attributes as well, then acts on all it's sub-classes class attributes as well but dynamically.

Sorry, but after looking into it a bit more, I don't have enough time to be the guy that breaks it.

from pyflp.

demberto avatar demberto commented on July 18, 2024

@ryanlong1004 It just resets the _count variable for all _Event and _FLObject subclasses. There is no reset method. Also what is "FLV"? Thanks anyways.

from pyflp.

demberto avatar demberto commented on July 18, 2024

Fixed in 1.1.0

from pyflp.

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.