@@ -8,19 +8,19 @@ class SourceFile:
8
8
TRIPLE_QUOTE = '"""'
9
9
10
10
def __init__ (self , filename : str , content : str ) -> None :
11
- self .unix_newlines : bool = "\r " not in content
12
- self .content_slice : Slice = Slice (content .replace ("\r \n " , "\n " ))
13
- self .language : Language = Language .from_filename (filename )
14
- self .escape_leading_whitespace = EscapeLeadingWhitespace .appropriate_for (
11
+ self .__unix_newlines : bool = "\r " not in content
12
+ self .__content_slice : Slice = Slice (content .replace ("\r \n " , "\n " ))
13
+ self .__language : Language = Language .from_filename (filename )
14
+ self .__escape_leading_whitespace = EscapeLeadingWhitespace .appropriate_for (
15
15
self .content_slice .__str__ ()
16
16
)
17
17
18
18
@property
19
19
def as_string (self ) -> str :
20
20
return (
21
- self .content_slice .__str__ ()
22
- if self .unix_newlines
23
- else self .content_slice .__str__ ().replace ("\n " , "\r \n " )
21
+ self .__content_slice .__str__ ()
22
+ if self .__unix_newlines
23
+ else self .__content_slice .__str__ ().replace ("\n " , "\r \n " )
24
24
)
25
25
26
26
class ToBeLiteral :
@@ -32,17 +32,17 @@ def __init__(
32
32
language : Language ,
33
33
escape_leading_whitespace : EscapeLeadingWhitespace ,
34
34
) -> None :
35
- self .dot_fun_open_paren = dot_fun_open_paren
36
- self .function_call_plus_arg = function_call_plus_arg
37
- self .arg = arg
38
- self .language = language
39
- self .escape_leading_whitespace = escape_leading_whitespace
35
+ self .__dot_fun_open_paren = dot_fun_open_paren
36
+ self .__function_call_plus_arg = function_call_plus_arg
37
+ self .__arg = arg
38
+ self .__language = language
39
+ self .__escape_leading_whitespace = escape_leading_whitespace
40
40
41
41
def set_literal_and_get_newline_delta (self , literal_value : LiteralValue ) -> int :
42
42
encoded = literal_value .format .encode (
43
- literal_value .actual , self .language , self .escape_leading_whitespace
43
+ literal_value .actual , self .__language , self .__escape_leading_whitespace
44
44
)
45
- round_tripped = literal_value .format .parse (encoded , self .language )
45
+ round_tripped = literal_value .format .parse (encoded , self .__language )
46
46
if round_tripped != literal_value .actual :
47
47
raise ValueError (
48
48
f"There is an error in { literal_value .format .__class__ .__name__ } , "
@@ -55,15 +55,15 @@ def set_literal_and_get_newline_delta(self, literal_value: LiteralValue) -> int:
55
55
f"ENCODED ORIGINAL\n { encoded } \n "
56
56
f"```\n "
57
57
)
58
- existing_newlines = self .function_call_plus_arg .count ("\n " )
58
+ existing_newlines = self .__function_call_plus_arg .count ("\n " )
59
59
new_newlines = encoded .count ("\n " )
60
- self .content_slice = self .function_call_plus_arg .replaceSelfWith (
61
- f"{ self .dot_fun_open_paren } { encoded } )"
60
+ self .content_slice = self .__function_call_plus_arg .replaceSelfWith (
61
+ f"{ self .__dot_fun_open_paren } { encoded } )"
62
62
)
63
63
return new_newlines - existing_newlines
64
64
65
65
def parse_literal (self , literal_format : LiteralFormat ) -> Any :
66
- return literal_format .parse (self .arg .__str__ (), self .language )
66
+ return literal_format .parse (self .__arg .__str__ (), self .__language )
67
67
68
68
def find_on_line (self , to_find : str , line_one_indexed : int ) -> Slice :
69
69
line_content = self .content_slice .unixLine (line_one_indexed )
@@ -174,8 +174,8 @@ def parse_to_be_like(self, line_one_indexed: int) -> ToBeLiteral:
174
174
dot_fun_open_paren .replace ("_TODO" , "" ),
175
175
self .content_slice .subSequence (dot_function_call , end_paren + 1 ),
176
176
self .content_slice .subSequence (arg_start , end_arg ),
177
- self .language ,
178
- self .escape_leading_whitespace ,
177
+ self .__language ,
178
+ self .__escape_leading_whitespace ,
179
179
)
180
180
181
181
0 commit comments