Additional validators

Overview

Path PyPoE/shared/config/validator.py
Version 1.0.0a0
Revision $Id: d9d1759ffa17c6e6a8716007ce6e18047e73bc73 $
Author Omega_K2

Description

Additional validators for configobj and validate.

Validator Function Generators

class PyPoE.shared.config.validator.IntEnumValidator(enum, default=None)[source]

Bases: object

Class to create a dynamic validator for IntEnum classes

__call__(value)[source]
Parameters:value (object) – The value to validate
Returns:the int enum instance if successfully validated or None
Return type:IntEnum
Raises:ValidateError – if the the value can’t be validated
__init__(enum, default=None)[source]
Parameters:
  • enum (enum.IntEnum) – base enum class for this validator
  • default (enum.IntEnum | int | None) – default attribute of the enum
Raises:

Validator Functions

PyPoE.shared.config.validator.is_file(value, *args, exists=True, allow_empty=False, **kwargs)[source]

Checks whether the value is a valid file path (and optionally whether it exists).

Parameters:
  • value (object) – The value to validate
  • exists (bool) – whether the file is required to exist to pass the validation check
  • allow_empty (bool) – whether empty strings are allowed
Returns:

the int enum instance if successfully validated or None

Return type:

IntEnum

Raises:

ValidateError – if the the value can’t be validated

PyPoE.shared.config.validator.is_directory(value, *args, exists=True, allow_empty=False, **kwargs)[source]

Checks whether the value is a valid directory path (and optionally whether it exists).

Parameters:
  • value (object) – The value to validate
  • exists (bool) – whether the directory is required to exist to pass the validation check
  • allow_empty (bool) – whether empty strings are allowed
Returns:

the int enum instance if successfully validated or None

Return type:

IntEnum

Raises:

ValidateError – if the the value can’t be validated

Agreement

See PyPoE/LICENSE