MCPcopy Create free account
hub / github.com/DeepL/deepl-python / DocumentStatus

Class DocumentStatus

deepl/api_data.py:68–124  ·  view source on GitHub ↗

Status of a document translation request. :param status: One of the Status enum values below. :param seconds_remaining: Estimated time until document translation completes in seconds, or None if unknown. :param billed_characters: Number of characters billed for this document, or

Source from the content-addressed store, hash-verified

66
67
68class DocumentStatus:
69 """Status of a document translation request.
70
71 :param status: One of the Status enum values below.
72 :param seconds_remaining: Estimated time until document translation
73 completes in seconds, or None if unknown.
74 :param billed_characters: Number of characters billed for this document, or
75 None if unknown or before translation is complete.
76 :param error_message: A short description of the error, or None if no error
77 has occurred.
78 """
79
80 class Status(Enum):
81 QUEUED = "queued"
82 TRANSLATING = "translating"
83 DONE = "done"
84 DOWNLOADED = "downloaded"
85 ERROR = "error"
86
87 def __init__(
88 self,
89 status: Status,
90 seconds_remaining=None,
91 billed_characters=None,
92 error_message=None,
93 ):
94 self._status = self.Status(status)
95 self._seconds_remaining = seconds_remaining
96 self._billed_characters = billed_characters
97 self._error_message = error_message
98
99 def __str__(self) -> str:
100 return self.status.value
101
102 @property
103 def ok(self) -> bool:
104 return self._status != self.Status.ERROR
105
106 @property
107 def done(self) -> bool:
108 return self._status == self.Status.DONE
109
110 @property
111 def status(self) -> Status:
112 return self._status
113
114 @property
115 def seconds_remaining(self) -> Optional[int]:
116 return self._seconds_remaining
117
118 @property
119 def billed_characters(self) -> Optional[int]:
120 return self._billed_characters
121
122 @property
123 def error_message(self) -> Optional[int]:
124 return self._error_message
125

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected