41
41
42
42
43
43
class File :
44
- _lines_of_code : int
45
- _character_count : int
46
- _parent_id : str
47
- _annotation : str
48
-
49
44
"""Represents a single file within a mystb.in paste.
50
45
51
46
Attributes
@@ -56,6 +51,11 @@ class File:
56
51
The file's contents.
57
52
"""
58
53
54
+ _lines_of_code : int
55
+ _character_count : int
56
+ _parent_id : str
57
+ _annotation : str
58
+
59
59
__slots__ = (
60
60
"_annotation" ,
61
61
"_character_count" ,
@@ -71,18 +71,42 @@ def __init__(self, *, filename: str, content: str) -> None:
71
71
72
72
@property
73
73
def lines_of_code (self ) -> int :
74
+ """The total lines of code this file has.
75
+
76
+ Returns
77
+ --------
78
+ :class:`int`
79
+ """
74
80
return self ._lines_of_code
75
81
76
82
@property
77
83
def character_count (self ) -> int :
84
+ """The total character count of this file.
85
+
86
+ Returns
87
+ --------
88
+ :class:`int`
89
+ """
78
90
return self ._character_count
79
91
80
92
@property
81
93
def annotation (self ) -> str :
94
+ """The files annotation.
95
+
96
+ Returns
97
+ --------
98
+ :class:`str`
99
+ """
82
100
return self ._annotation
83
101
84
102
@property
85
103
def parent_id (self ) -> str :
104
+ """The files parent paste ID.
105
+
106
+ Returns
107
+ --------
108
+ :class:`str`
109
+ """
86
110
return self ._parent_id
87
111
88
112
@classmethod
@@ -103,10 +127,6 @@ def to_dict(self) -> dict[str, Any]:
103
127
104
128
105
129
class Paste :
106
- _expires : datetime .datetime | None
107
- _views : int | None
108
- _security : str | None
109
-
110
130
"""Represents a Paste object from mystbin instances.
111
131
112
132
Attributes
@@ -119,6 +139,10 @@ class Paste:
119
139
The list of files within this Paste.
120
140
"""
121
141
142
+ _expires : datetime .datetime | None
143
+ _views : int | None
144
+ _security : str | None
145
+
122
146
__slots__ = (
123
147
"_expires" ,
124
148
"_http" ,
@@ -144,18 +168,42 @@ def __repr__(self) -> str:
144
168
145
169
@property
146
170
def url (self ) -> str :
147
- return f"{ self ._http .api_base } { self .id } "
171
+ """The paste URL.
172
+
173
+ Returns
174
+ --------
175
+ :class:`str`
176
+ """
177
+ return f"{ self ._http .root_url } { self .id } "
148
178
149
179
@property
150
180
def expires (self ) -> datetime .datetime | None :
181
+ """When the paste expires, if at all.
182
+
183
+ Returns
184
+ --------
185
+ Optional[:class:`datetime.datetime`]
186
+ """
151
187
return self ._expires
152
188
153
189
@property
154
190
def views (self ) -> int | None :
191
+ """The pastes view count, if any.
192
+
193
+ Returns
194
+ --------
195
+ Optional[:class:`int`]
196
+ """
155
197
return self ._views
156
198
157
199
@property
158
200
def security_token (self ) -> str | None :
201
+ """The pastes security token, if any.
202
+
203
+ Returns
204
+ --------
205
+ Optional[:class:`str`]
206
+ """
159
207
return self ._security
160
208
161
209
@classmethod
@@ -200,6 +248,15 @@ def from_create(cls, payload: CreatePasteResponse, files: Sequence[File], *, htt
200
248
return self
201
249
202
250
async def delete (self ) -> None :
251
+ """|coro|
252
+
253
+ This method will delete this paste from the mystbin instance.
254
+
255
+ Raises
256
+ -------
257
+ ValueError
258
+ The paste requires the security token to be present.
259
+ """
203
260
if not self .security_token :
204
261
raise ValueError ("Cannot delete a Paste with no Security Token set." )
205
262
0 commit comments