pyfarm.models.core.functions module¶
Functions¶
Contains core functions and data for use by pyfarm.models
-
pyfarm.models.core.functions.
getuuid
(value, table, table_attrib, error_tail)[source]¶ Returns the proper value for the given input. Depending on the type being provided this will return one of the following:
- None
- the value from an attribute
- string from a UUID
- the original value (after validating it’s a UUID)
Parameters: - value (string) – the value to validate and returning data from
- table (string) – the table which the provided value belongs to
- table_attrib (string) – the attribute to use when attempting to pull data off of a model object
- error_tail (string) – added to the end of error messages
- error_text (str) – error text to render in the event of problems
Raises ValueError: raised when the provided input is invalid, blank, or otherwise unexpected
-
pyfarm.models.core.functions.
modelfor
(model, table)[source]¶ Returns True if the given model object is for the expected table.
>>> from pyfarm.master.config import config >>> from pyfarm.models.agent import Agent >>> modelfor(Agent("foo", "10.56.0.0", "255.0.0.0"), config.get("table_agent")) True
-
pyfarm.models.core.functions.
repr_enum
(value, enum=None)[source]¶ produces the string representation of an enum value