@@ -8,19 +8,19 @@ class SourceFile:
88 TRIPLE_QUOTE = '"""'
99
1010 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 (
1515 self .content_slice .__str__ ()
1616 )
1717
1818 @property
1919 def as_string (self ) -> str :
2020 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 " )
2424 )
2525
2626 class ToBeLiteral :
@@ -32,17 +32,17 @@ def __init__(
3232 language : Language ,
3333 escape_leading_whitespace : EscapeLeadingWhitespace ,
3434 ) -> 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
4040
4141 def set_literal_and_get_newline_delta (self , literal_value : LiteralValue ) -> int :
4242 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
4444 )
45- round_tripped = literal_value .format .parse (encoded , self .language )
45+ round_tripped = literal_value .format .parse (encoded , self .__language )
4646 if round_tripped != literal_value .actual :
4747 raise ValueError (
4848 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:
5555 f"ENCODED ORIGINAL\n { encoded } \n "
5656 f"```\n "
5757 )
58- existing_newlines = self .function_call_plus_arg .count ("\n " )
58+ existing_newlines = self .__function_call_plus_arg .count ("\n " )
5959 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 } )"
6262 )
6363 return new_newlines - existing_newlines
6464
6565 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 )
6767
6868 def find_on_line (self , to_find : str , line_one_indexed : int ) -> Slice :
6969 line_content = self .content_slice .unixLine (line_one_indexed )
@@ -174,8 +174,8 @@ def parse_to_be_like(self, line_one_indexed: int) -> ToBeLiteral:
174174 dot_fun_open_paren .replace ("_TODO" , "" ),
175175 self .content_slice .subSequence (dot_function_call , end_paren + 1 ),
176176 self .content_slice .subSequence (arg_start , end_arg ),
177- self .language ,
178- self .escape_leading_whitespace ,
177+ self .__language ,
178+ self .__escape_leading_whitespace ,
179179 )
180180
181181
0 commit comments