Skip to content

temporal

ASTx Data Types module.

Classes:

LiteralDate

LiteralDate(value: str, loc: SourceLocation = NO_SOURCE_LOCATION)

Bases: Literal

LiteralDate data type class.

Methods:

  • get_struct

    Return the structure of the LiteralDate object.

  • to_json

    Return an json string that represents the object.

  • to_yaml

    Return an yaml string that represents the object.

Source code in src/astx/literals/temporal.py
27
28
29
30
31
32
33
34
def __init__(
    self, value: str, loc: SourceLocation = NO_SOURCE_LOCATION
) -> None:
    """Initialize LiteralDate."""
    super().__init__(loc)
    self.value = value
    self.type_ = Date()
    self.loc = loc

get_struct

get_struct(simplified: bool = False) -> ReprStruct

Return the structure of the LiteralDate object.

Source code in src/astx/literals/temporal.py
40
41
42
43
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """Return the structure of the LiteralDate object."""
    key = f"LiteralDate: {self.value}"
    return self._prepare_struct(key, self.value, simplified)

to_json

to_json(simplified: bool = False) -> str

Return an json string that represents the object.

Source code in src/astx/base.py
265
266
267
def to_json(self, simplified: bool = False) -> str:
    """Return an json string that represents the object."""
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str

Return an yaml string that represents the object.

Source code in src/astx/base.py
259
260
261
262
263
def to_yaml(self, simplified: bool = False) -> str:
    """Return an yaml string that represents the object."""
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

LiteralDateTime

LiteralDateTime(value: str, loc: SourceLocation = NO_SOURCE_LOCATION)

Bases: Literal

LiteralDateTime data type class.

Methods:

  • get_struct

    Return the structure of the LiteralDateTime object.

  • to_json

    Return an json string that represents the object.

  • to_yaml

    Return an yaml string that represents the object.

Source code in src/astx/literals/temporal.py
 99
100
101
102
103
104
105
106
def __init__(
    self, value: str, loc: SourceLocation = NO_SOURCE_LOCATION
) -> None:
    """Initialize LiteralDateTime."""
    super().__init__(loc)
    self.value = value
    self.type_ = DateTime()
    self.loc = loc

get_struct

get_struct(simplified: bool = False) -> ReprStruct

Return the structure of the LiteralDateTime object.

Source code in src/astx/literals/temporal.py
112
113
114
115
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """Return the structure of the LiteralDateTime object."""
    key = f"LiteralDateTime: {self.value}"
    return self._prepare_struct(key, self.value, simplified)

to_json

to_json(simplified: bool = False) -> str

Return an json string that represents the object.

Source code in src/astx/base.py
265
266
267
def to_json(self, simplified: bool = False) -> str:
    """Return an json string that represents the object."""
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str

Return an yaml string that represents the object.

Source code in src/astx/base.py
259
260
261
262
263
def to_yaml(self, simplified: bool = False) -> str:
    """Return an yaml string that represents the object."""
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

LiteralTime

LiteralTime(value: str, loc: SourceLocation = NO_SOURCE_LOCATION)

Bases: Literal

LiteralTime data type class.

Methods:

  • get_struct

    Return the structure of the LiteralTime object.

  • to_json

    Return an json string that represents the object.

  • to_yaml

    Return an yaml string that represents the object.

Source code in src/astx/literals/temporal.py
51
52
53
54
55
56
57
58
def __init__(
    self, value: str, loc: SourceLocation = NO_SOURCE_LOCATION
) -> None:
    """Initialize LiteralTime."""
    super().__init__(loc)
    self.value = value
    self.type_ = Time()
    self.loc = loc

get_struct

get_struct(simplified: bool = False) -> ReprStruct

Return the structure of the LiteralTime object.

Source code in src/astx/literals/temporal.py
64
65
66
67
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """Return the structure of the LiteralTime object."""
    key = f"LiteralTime: {self.value}"
    return self._prepare_struct(key, self.value, simplified)

to_json

to_json(simplified: bool = False) -> str

Return an json string that represents the object.

Source code in src/astx/base.py
265
266
267
def to_json(self, simplified: bool = False) -> str:
    """Return an json string that represents the object."""
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str

Return an yaml string that represents the object.

Source code in src/astx/base.py
259
260
261
262
263
def to_yaml(self, simplified: bool = False) -> str:
    """Return an yaml string that represents the object."""
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

LiteralTimestamp

LiteralTimestamp(value: str, loc: SourceLocation = NO_SOURCE_LOCATION)

Bases: Literal

LiteralTimestamp data type class.

Methods:

  • get_struct

    Return the structure of the LiteralTimestamp object.

  • to_json

    Return an json string that represents the object.

  • to_yaml

    Return an yaml string that represents the object.

Source code in src/astx/literals/temporal.py
75
76
77
78
79
80
81
82
def __init__(
    self, value: str, loc: SourceLocation = NO_SOURCE_LOCATION
) -> None:
    """Initialize LiteralTimestamp."""
    super().__init__(loc)
    self.value = value
    self.type_ = Timestamp()
    self.loc = loc

get_struct

get_struct(simplified: bool = False) -> ReprStruct

Return the structure of the LiteralTimestamp object.

Source code in src/astx/literals/temporal.py
88
89
90
91
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """Return the structure of the LiteralTimestamp object."""
    key = f"LiteralTimestamp: {self.value}"
    return self._prepare_struct(key, self.value, simplified)

to_json

to_json(simplified: bool = False) -> str

Return an json string that represents the object.

Source code in src/astx/base.py
265
266
267
def to_json(self, simplified: bool = False) -> str:
    """Return an json string that represents the object."""
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str

Return an yaml string that represents the object.

Source code in src/astx/base.py
259
260
261
262
263
def to_yaml(self, simplified: bool = False) -> str:
    """Return an yaml string that represents the object."""
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )