Beispiel #1
0
def is_file_path(s):
    if s.startswith('file'):
        return True
    return False


def is_email(s):
    return '@' in s


def to_epoch(v):
    return common.helpers.to_epoch(v)


HttpPathString = All(unicode,
                 Msg(truth(is_http_path),
                     'path must start with "http[s]://"'))

FilePathString = All(unicode,
                 Msg(truth(is_file_path),
                     'path must start with "file://"'))


class Doc(Marker):
    """Attach documentation to this voluptuous node.
    """
    def __init__(self, schema, docstring, *args, **kwargs):
        super(Doc, self).__init__(schema, *args, **kwargs)
        self.docstring = docstring

Beispiel #2
0
    error_string += ' is required'
    error = Invalid(error_string)
    raise MultipleInvalid(errors=[error])


def is_path(s):
    return s[0] == '/' or s.startswith('file://') or s.startswith('hdfs://')


def is_email(s):
    return '@' in s


PathString = All(unicode,
                 Length(min=1),
                 Msg(truth(is_path),
                     'path must start with "/", "file://" or "hdfs://"'))


########
# Runs #
########

CreateRun = Schema({
    Required('uri'): PathString,

    # One of `project` is required, but not supported in voluptuous, so we
    # enforce this in code. cf. https://github.com/alecthomas/voluptuous/issues/115
    Exclusive('project_id', 'project'): Coerce(int),
    Exclusive('project_name', 'project'): unicode,
Beispiel #3
0
_LOGGER = logging.getLogger(__name__)
RFXOBJECT = None


def validate_packetid(value):
    """Validate that value is a valid packet id for rfxtrx."""
    if get_rfx_object(value):
        return value
    else:
        raise vol.Invalid('invalid packet id for {}'.format(value))


# Share between rfxtrx platforms
VALID_DEVICE_ID = vol.All(cv.string, vol.Lower)
VALID_SENSOR_DEVICE_ID = vol.All(
    VALID_DEVICE_ID, vol.truth(lambda val: val.startswith('sensor_')))

DEVICE_SCHEMA = vol.Schema({
    vol.Required(ATTR_NAME):
    cv.string,
    vol.Required(ATTR_PACKETID):
    validate_packetid,
    vol.Optional(ATTR_FIREEVENT, default=False):
    cv.boolean,
})

DEFAULT_SCHEMA = vol.Schema({
    vol.Required("platform"):
    DOMAIN,
    vol.Required(CONF_DEVICES): {
        cv.slug: DEVICE_SCHEMA
Beispiel #4
0
RFX_DEVICES = {}
_LOGGER = logging.getLogger(__name__)
RFXOBJECT = None


def validate_packetid(value):
    """Validate that value is a valid packet id for rfxtrx."""
    if get_rfx_object(value):
        return value
    else:
        raise vol.Invalid('invalid packet id for {}'.format(value))

# Share between rfxtrx platforms
VALID_DEVICE_ID = vol.All(cv.string, vol.Lower)
VALID_SENSOR_DEVICE_ID = vol.All(VALID_DEVICE_ID,
                                 vol.truth(lambda val:
                                           val.startswith('sensor_')))

DEVICE_SCHEMA = vol.Schema({
    vol.Required(ATTR_NAME): cv.string,
    vol.Required(ATTR_PACKETID): validate_packetid,
    vol.Optional(ATTR_FIREEVENT, default=False): cv.boolean,
})

DEFAULT_SCHEMA = vol.Schema({
    vol.Required("platform"): DOMAIN,
    vol.Required(CONF_DEVICES): {cv.slug: DEVICE_SCHEMA},
    vol.Optional(ATTR_AUTOMATIC_ADD, default=False):  cv.boolean,
    vol.Optional(CONF_SIGNAL_REPETITIONS, default=DEFAULT_SIGNAL_REPETITIONS):
        vol.Coerce(int),
})