Giter Site home page Giter Site logo

Comments (6)

ChristianTremblay avatar ChristianTremblay commented on August 22, 2024 1

You are right. who is not used. We can remove that line.
Merci !
Regarding the docstring, I'm heading toward this, hoping it will be clearer.

    """
    point is either the ID of the writeable point entity, or an instance of
    the writeable point entity to retrieve the write status of or write a
    value to.

    To retrieve the write status of the point, value, duration and level are required to be None.
    To write to a point, value and level are required and duration is optional.
    """

Function will become

def _on_point_write(self, point, level, val, who, duration, callback, **kwargs):
    args = {"id": self._obj_to_ref(point)}
    if level is None:
        if (val is not None) or (duration is not None):
            raise ValueError(
                "You tried writing a value without specifying a level (or specified a duration without providing a level neither a value. Please provide required level. If trying to retrieve write status of the point, provide None as value, duration and level"
            )
    else:
        args.update({"level": level, "val": val})
        if who is not None:
            args["who"] = who
        if duration is not None:
            args["duration"] = duration
    return self._get_grid("pointWrite", callback, args=args, **kwargs)

from pyhaystack.

ChristianTremblay avatar ChristianTremblay commented on August 22, 2024

What if you explicitly pass who=None ?

from pyhaystack.

ChristianTremblay avatar ChristianTremblay commented on August 22, 2024

Forgot to ask, using this in skyspark ? nhaystack or widesky ?

from pyhaystack.

ChristianTremblay avatar ChristianTremblay commented on August 22, 2024

What if you explicitly pass who=None ?

Nevermind... it'll be overridden...

from pyhaystack.

ChristianTremblay avatar ChristianTremblay commented on August 22, 2024

Please, try the develop branch where I modified the behaviour so who will be reset to None in the case where level is None.

from pyhaystack.

jdechalendar avatar jdechalendar commented on August 22, 2024

Sorry for not replying earlier. Just saw the change here

  • Does it make sense to change the error message to remove the requirement for who to be None as the value for who will not be considered if level is None.
  • In the first part of the if statement, you set who to be None, but that does seem to be used - is that line needed?

With these suggestions, the on_point_write method would become:

def _on_point_write(self, point, level, val, who, duration, callback, **kwargs):
        args = {"id": self._obj_to_ref(point)}
        if level is None:  # Ignore value for who as it may be username
            if (val is not None) or (duration is not None):
                raise ValueError(
                    "If level is None, val and duration must be None too."
                )
        else:
            args.update({"level": level, "val": val})
            if who is not None:
                args["who"] = who
            if duration is not None:
                args["duration"] = duration
        return self._get_grid("pointWrite", callback, args=args, **kwargs)

It may also be worth updating the docstring of the point_write method to reflect the change: If level is None, the val and duration parameters should be None too, the write status of the point is retrieved.

from pyhaystack.

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.