Best Python code snippet using pandera_python
config_model.py
Source:config_model.py
...35 password -> "boo!"36 foo_password -> "boo!_foo"37 """38 @classmethod39 def __get_validators__(cls):40 yield cls.validate41 @classmethod42 def validate(cls, v):43 if found_vars := list(filter(len, chain.from_iterable(_var_re.findall(v)))):44 for var in found_vars:45 if (var_val := os.getenv(var)) is None:46 raise ValueError(f'Environment variable "{var}" missing.')47 if not len(var_val):48 raise ValueError(f'Environment variable "{var}" empty.')49 return expandvars(v)50 return v51class EnvSecretStr(EnvExpand, SecretStr):52 @classmethod53 def validate(cls, v):54 return SecretStr.validate(EnvExpand.validate(v))55class Credentials(NoExtraBaseModel):56 username: Optional[EnvExpand]57 password: Optional[EnvSecretStr]58 token: Optional[EnvSecretStr]59 @root_validator()60 def ensure_credentials(cls, values):61 if not any(62 (all((values.get("username"), values.get("password"))), values["token"])63 ):64 raise ValueError("Missing required credentials")65 return values66class FilePathEnvExpand(FilePath):67 """ A FilePath field whose value can interpolated from env vars """68 @classmethod69 def __get_validators__(cls):70 yield from EnvExpand.__get_validators__()71 yield from FilePath.__get_validators__()72class DirPathEnvExpand(DirectoryPath):73 """ A DirectoryPath field whose value can interpolated from env vars """74 @classmethod75 def __get_validators__(cls):76 yield from EnvExpand.__get_validators__()77 yield from DirectoryPath.__get_validators__()78class Defaults(NoExtraBaseModel, BaseSettings):79 configs_dir: DirPathEnvExpand80 @validator("configs_dir")81 def _configs_dir(cls, value): # noqa82 return Path(value).absolute()83class IPFabricModel(NoExtraBaseModel):84 server_url: EnvExpand85 credentials: Credentials86 filters: Optional[str]87 strip_hostname_domains: Optional[List[str]]88class GitSpec(NoExtraBaseModel):89 name: Optional[str]90 repo: str91 email: Optional[str]...
_validator.py
Source:_validator.py
1from pydantic import validator2class Identifcation(str):3 @classmethod4 def __get_validators__(cls):5 yield cls.validate_ID6 @classmethod7 def validate_ID(cls, v: str) -> str:8 print(v)9 return v10class LengthDataset(int):11 @classmethod12 def __get_validators__(cls) -> None:13 yield cls.validate_LEN14 @classmethod15 def validate_LEN(cls, v: int) -> int:16 print(v)17 return v18class NextElementAvailable(int):19 @classmethod20 def __get_validators__(cls) -> None:21 yield cls.validate_NA22 @classmethod23 def validate_NA(cls, v: int) -> int:24 print(v)25 return v26class MeasuringPoint(str):27 @classmethod28 def __get_validators__(cls) -> None:29 yield cls.validate_MP30 @classmethod31 def validate_MP(cls, v: str) -> str:32 print(v)33 return v34class ModuleType(str):35 @classmethod36 def __get_validators__(cls) -> None:37 yield cls.validate_MT38 @classmethod39 def validate_MT(cls, v: str) -> str:40 print(v)41 return v42class ShortText(str):43 @classmethod44 def __get_validators__(cls) -> None:45 yield cls.validate_MT46 @classmethod47 def validate_ST(cls, v: str) -> str:48 print(v)49 return v50class LongText(str):51 @classmethod52 def __get_validators__(cls) -> None:53 yield cls.validate_LT54 @classmethod55 def validate_LT(cls, v: str) -> str:56 print(v)57 return v58class AreaDefinition(int):59 @classmethod60 def __get_validators__(cls) -> None:61 yield cls.validate_AD62 @classmethod63 def validate_AD(cls, v: int) -> int:64 print(v)65 return v66class StatusBit(int):67 @classmethod68 def __get_validators__(cls) -> None:69 yield cls.validate_SB70 @classmethod71 def validate_SB(cls, v: int) -> int:72 print(v)73 return v74class VariableName(str):75 @classmethod76 def __get_validators__(cls) -> None:77 yield cls.validate_VN78 @classmethod79 def validate_VN(cls, v: str) -> str:80 print(v)81 return v82class DataTyp(str):83 @classmethod84 def __get_validators__(cls) -> None:85 yield cls.validate_DT86 @classmethod87 def validate_DT(cls, v: str) -> str:88 print(v)89 return v90class VariableText(str):91 @classmethod92 def __get_validators__(cls) -> None:93 yield cls.validate_VT94 @classmethod95 def validate_VT(cls, v: str) -> str:96 print(v)97 return v98class ProcessImage(str):99 @classmethod100 def __get_validators__(cls) -> None:101 yield cls.validate_PI102 @classmethod103 def validate_PI(cls, v: str) -> str:104 print(v)105 return v106class ExportedVariable(str):107 @classmethod108 def __get_validators__(cls) -> None:109 yield cls.validate_EV110 @classmethod111 def validate_EV(cls, v: str) -> str:112 print(v)113 return v114class VariableOrConst(str):115 @classmethod116 def __get_validators__(cls) -> None:117 yield cls.validate_VC118 @classmethod119 def validate_VC(cls, v: str) -> str:120 print(v)121 return v122class Fbs(str):123 @classmethod124 def __get_validators__(cls) -> None:125 yield cls.validate_FB126 @classmethod127 def validate_FB(cls, v: str) -> str:128 print(v)129 return v130class Libary:131 @classmethod132 def __get_validators__(cls) -> None:133 yield cls.validate_LB134 @classmethod135 def validate_LB(cls, v: str) -> str:136 print(v)137 return v138class DtmNumber():139 pass140class DtmConfig():141 pass142class QuantityCounter():143 pass144class FunctionName():145 pass146class ChannelName():...
base.py
Source:base.py
...3import orjson4from core.config import TIME_DOMAIN_SUB_SAMPLED_RATIO, TIME_DOMAIN_DECIMAL5class SubSampledBinaryArray(list):6 @classmethod7 def __get_validators__(cls):8 yield cls.validate9 @classmethod10 def validate(cls, v):11 raw = np.fromstring(v, dtype=np.float32)12 axis = np.linspace(13 0, raw.size, int(raw.size / TIME_DOMAIN_SUB_SAMPLED_RATIO), endpoint=False14 )15 return [16 round(float(item), TIME_DOMAIN_DECIMAL)17 for item in np.take(raw, axis.astype(np.int))18 ]19class BinaryArray(list):20 @classmethod21 def __get_validators__(cls):22 yield cls.validate23 @classmethod24 def validate(cls, v):25 raw = np.fromstring(v, dtype=np.float32)26 return [round(float(item), TIME_DOMAIN_DECIMAL) for item in raw]27class BinaryArrayMax(list):28 @classmethod29 def __get_validators__(cls):30 yield cls.validate31 @classmethod32 def validate(cls, v):33 raw = np.fromstring(v, dtype=np.float32)34 return float(raw.max())35class SubSampledArray(list):36 @classmethod37 def __get_validators__(cls):38 yield cls.validate39 @classmethod40 def validate(cls, v: ndarray):41 axis = np.linspace(42 0, v.size, int(v.size / TIME_DOMAIN_SUB_SAMPLED_RATIO), endpoint=False43 )44 return [45 round(float(item), TIME_DOMAIN_DECIMAL)46 for item in np.take(v, axis.astype(np.int))47 ]48class SignalArray(list):49 @classmethod50 def __get_validators__(cls):51 yield cls.validate52 @classmethod53 def validate(cls, v: ndarray):54 return [round(float(item), TIME_DOMAIN_DECIMAL) for item in v]55class SignalArrayWithoutRound(list):56 @classmethod57 def __get_validators__(cls):58 yield cls.validate59 @classmethod60 def validate(cls, v: ndarray):61 return [float(item) for item in v]62class JsonString(list):63 @classmethod64 def __get_validators__(cls):65 yield cls.validate66 @classmethod67 def validate(cls, v: str):...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!