#!/usr/bin/env python3 # -*- coding: utf-8 -*- from typing import Self, Any, Optional from Interfaces.FormatModuleInterface import FormatModuleInterface from Utils.Patterns import RE from Utils.Check import Check from Utils.Utils import Utils class RangeFormat: def __init__(self:Self, format:FormatModuleInterface, options:Optional[dict[str, Any|None]] = None ) -> None: self.format:FormatModuleInterface = format def get(self:Self, i:int, inputs:str|list[Any|None], shared:dict[str, Any|None] = {}, fragments:list[str] = [] ) -> str: inputs = ( [ int(value) for value in str(Utils.get_random(inputs.split("|"))).split("-") ] if Check.is_string(inputs) else inputs if Check.is_array(inputs) else []) if Check.is_number(inputs): return str(inputs) l = len(inputs) return str( None if not l else inputs[0] if l == 1 else Utils.get_random(*inputs)) def check(self:Self, i:int, string:str, inputs:str|list[Any|None], shared:dict[str, Any|None] = {}, fragments:list[str] = [] ) -> int: return self.format.check_range(string, inputs)