Skip to content

Commit

Permalink
rename as_popo to unwrap; add recursive arg
Browse files Browse the repository at this point in the history
  • Loading branch information
syntapy committed Apr 14, 2022
1 parent 0e376a0 commit 423f6b1
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tomlkit/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def as_string(self) -> str:
"""The TOML representation"""
raise NotImplementedError()

def as_ppo(self):
def unwrap(self, recursive: bool = True):
"""Returns as pure python object (ppo)"""
raise NotImplementedError()

Expand Down Expand Up @@ -550,7 +550,7 @@ def __init__(self, _: int, trivia: Trivia, raw: str) -> None:
if re.match(r"^[+\-]\d+$", raw):
self._sign = True

def as_ppo(self) -> int:
def unwrap(self, recursive: bool = True) -> int:
return int(self)

@property
Expand Down Expand Up @@ -621,7 +621,7 @@ def __init__(self, _: float, trivia: Trivia, raw: str) -> None:
if re.match(r"^[+\-].+$", raw):
self._sign = True

def as_ppo(self) -> float:
def unwrap(self, recursive: bool = True) -> float:
return float(self)

@property
Expand Down Expand Up @@ -685,7 +685,7 @@ def __init__(self, t: int, trivia: Trivia) -> None:

self._value = bool(t)

def as_ppo(self) -> bool:
def unwrap(self, recursive: bool = True) -> bool:
return bool(self)

@property
Expand Down Expand Up @@ -770,7 +770,7 @@ def __init__(

self._raw = raw

def as_ppo(self) -> datetime:
def unwrap(self, recursive: bool = True) -> datetime:
(year, month, day, hour, minute, second, microsecond, tzinfo, _, _) = self._getstate()
return datetime(year, month, day, hour, minute, second, microsecond, tzinfo)

Expand Down Expand Up @@ -868,7 +868,7 @@ def __init__(

self._raw = raw

def as_ppo(self) -> date:
def unwrap(self, recursive: bool = True) -> date:
(year, month, day, _, _) = self._getstate()
return date(year, month, day)

Expand Down Expand Up @@ -941,7 +941,7 @@ def __init__(

self._raw = raw

def as_ppo(self) -> datetime:
def unwrap(self, recursive: bool = True) -> datetime:
(hour, minute, second, microsecond, tzinfo, _, _) = self._getstate()
return time(hour, minute, second, microsecond, tzinfo)

Expand Down Expand Up @@ -1228,7 +1228,7 @@ def __init__(self, value: "container.Container", trivia: Trivia):
if k is not None:
dict.__setitem__(self, k.key, v)

def as_ppo(self):
def unwrap(self, recursive: bool = True):
pass

@property
Expand Down Expand Up @@ -1553,7 +1553,7 @@ def __init__(self, t: StringType, _: str, original: str, trivia: Trivia) -> None
self._t = t
self._original = original

def as_ppo(self) -> str:
def unwrap(self, recursive: bool = True) -> str:
return self.as_string()

@property
Expand Down

0 comments on commit 423f6b1

Please sign in to comment.