コード例 #1
0
class Pet(UserObject, RegistersSubclasses, ABC):
    pet_type: str = UserProperty(str)
    name: str = UserProperty(str)

    @abstractmethod
    def speak(self):
        pass
コード例 #2
0
ファイル: yaml_module.py プロジェクト: jetavator/wysdom
class Vehicle(UserObject):
    color: str = UserProperty(str)
    description: str = UserProperty(str)

    @property
    def license(self):
        return key(self)
コード例 #3
0
ファイル: dict_module.py プロジェクト: jetavator/wysdom
class Person(UserObject):
    first_name: str = UserProperty(str)
    last_name: str = UserProperty(str)
    current_address: Address = UserProperty(
        Address, default_function=lambda person: person.previous_addresses[0])
    previous_addresses: List[Address] = ListProperty(Address)
    vehicles: Dict[str, Vehicle] = DictProperty(Vehicle,
                                                key_pattern=r"^[a-f0-9]{6}$",
                                                default={},
                                                persist_defaults=True)
コード例 #4
0
class Cat(Pet):
    pet_type: str = UserProperty(SchemaConst("cat"))

    def speak(self):
        return f"{self.name} says Miaow!"
コード例 #5
0
class Person(UserObject):
    first_name: str = UserProperty(str)
    last_name: str = UserProperty(str)
    pets: List[Pet] = UserProperty(SchemaArray(Pet))
コード例 #6
0
class Greyhound(Dog):
    pet_type: str = UserProperty(SchemaConst("greyhound"))

    def speak(self):
        return f"{self.name}, the greyhound, says Woof!"
コード例 #7
0
ファイル: yaml_module.py プロジェクト: jetavator/wysdom
class Person(UserObject, ReadsYAML):
    first_name: str = UserProperty(str)
    last_name: str = UserProperty(str)
    current_address: Address = UserProperty(Address)
    previous_addresses: List[Address] = UserProperty(SchemaArray(Address))
    vehicles: Dict[str, Vehicle] = UserProperty(SchemaDict(Vehicle))
コード例 #8
0
ファイル: yaml_module.py プロジェクト: jetavator/wysdom
class Address(UserObject):
    first_line: str = UserProperty(str)
    second_line: str = UserProperty(str)
    city: str = UserProperty(str)
    postal_code: str = UserProperty(int)
コード例 #9
0
class Address(UserObject):
    zip_code: int = UserProperty(int, pattern=r"^[0-9]{5}$")
コード例 #10
0
ファイル: dict_module.py プロジェクト: jetavator/wysdom
class Address(UserObject):
    first_line: str = UserProperty(str, pattern=r"^(\d)+.*$")
    second_line: str = UserProperty(str, optional=True)
    city: str = UserProperty(str)
    postal_code: str = UserProperty(int)
コード例 #11
0
class Person(UserObject):
    first_name: str = UserProperty(str)
    last_name: str = UserProperty(str, default="", optional=False)
コード例 #12
0
class Person(UserObject):
    first_name: str = UserProperty(str)
    last_name: str = UserProperty(str,
                                  default="",
                                  default_function=lambda x: x.first_name)