File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 38
38
39
39
40
40
class File :
41
+ """Represents a single file within a mystb.in paste.
42
+
43
+ Attributes
44
+ -----------
45
+ filename: :class:`str`
46
+ The file's name.
47
+ content: :class:`str`
48
+ The file's contents.
49
+ syntax: Optional[:class:`str`]
50
+ The file's syntax, if given.
51
+ lines_of_code: Optional[:class:`int`]
52
+ The lines of code within the file.
53
+ character_count: Optional[:class:`int`]
54
+ The character count of the file.
55
+
56
+
57
+ .. note::
58
+ The ``lines_of_code`` and ``character_count`` come from the API and should not be provided by the user.
59
+ """
60
+
41
61
__slots__ = (
42
62
"filename" ,
43
63
"content" ,
@@ -58,7 +78,7 @@ def __init__(
58
78
self .filename : str = filename
59
79
self .content : str = content
60
80
self .syntax : Optional [str ] = syntax
61
- self .lines_of_code : int = lines_of_code or len ( content .split ("\n " ) )
81
+ self .lines_of_code : int = lines_of_code or content .count ("\n " )
62
82
self .character_count : int = character_count or len (content )
63
83
64
84
@classmethod
You can’t perform that action at this time.
0 commit comments