@@ -30,7 +30,7 @@ def decode(value: str) -> Union[Dict[str, Any], List[Any], str]:
3030 Returns:
3131 Union[Dict[str,Any], List[Any], str]: The decoded value
3232 """
33- return __internal_decode (value , False )
33+ return _internal_decode (value , False )
3434
3535
3636def reduced_decode (value : str ) -> Union [Dict [str , Any ], List [Any ], str ]:
@@ -43,10 +43,10 @@ def reduced_decode(value: str) -> Union[Dict[str, Any], List[Any], str]:
4343 Returns:
4444 Union[Dict[str,Any], List[Any], str]: The decoded value
4545 """
46- return __internal_decode (value , True )
46+ return _internal_decode (value , True )
4747
4848
49- def __validateSuffix (restli_encoded_str : str , suffix : str ):
49+ def _validateSuffix (restli_encoded_str : str , suffix : str ):
5050 """
5151 Validates that the input restli_encoded_str has the expected suffix at the end
5252 """
@@ -56,7 +56,7 @@ def __validateSuffix(restli_encoded_str: str, suffix: str):
5656 )
5757
5858
59- def __restli_unescape (value : str , reduced : bool ):
59+ def _restli_unescape (value : str , reduced : bool ):
6060 if not reduced :
6161 value = unquote (value )
6262 elif re .search (reduced_decode_special_chars_pattern , value ):
@@ -68,7 +68,7 @@ def __restli_unescape(value: str, reduced: bool):
6868 return value
6969
7070
71- def __find_last_right_bracket (value : str , pos : int ) -> int :
71+ def _find_last_right_bracket (value : str , pos : int ) -> int :
7272 """
7373 Returns the index of the last right, matching bracket, starting from specified index.
7474 For example, consider value = "List(1,(k:v))".
@@ -111,21 +111,21 @@ def __find_last_right_bracket(value: str, pos: int) -> int:
111111 return idx
112112
113113
114- def __internal_decode (restli_encoded_str : str , reduced : bool ):
114+ def _internal_decode (restli_encoded_str : str , reduced : bool ):
115115 if (restli_encoded_str is None ) or (restli_encoded_str == "''" ):
116116 restli_encoded_str = ""
117117
118118 if restli_encoded_str .startswith (LIST_PREFIX ):
119- __validateSuffix (restli_encoded_str , LIST_SUFFIX )
120- return __decode_list (restli_encoded_str [5 :- 1 ], reduced )
119+ _validateSuffix (restli_encoded_str , LIST_SUFFIX )
120+ return _decode_list (restli_encoded_str [5 :- 1 ], reduced )
121121 elif restli_encoded_str .startswith (OBJ_PREFIX ):
122- __validateSuffix (restli_encoded_str , OBJ_SUFFIX )
123- return __decode_object (restli_encoded_str [1 :- 1 ], reduced )
122+ _validateSuffix (restli_encoded_str , OBJ_SUFFIX )
123+ return _decode_object (restli_encoded_str [1 :- 1 ], reduced )
124124 else :
125- return __restli_unescape (restli_encoded_str , reduced )
125+ return _restli_unescape (restli_encoded_str , reduced )
126126
127127
128- def __decode_list (restli_encoded_str : str , reduced : bool ) -> List [Any ]:
128+ def _decode_list (restli_encoded_str : str , reduced : bool ) -> List [Any ]:
129129 """
130130 Decodes a Rest.li-encoded string to a list
131131
@@ -147,9 +147,9 @@ def __decode_list(restli_encoded_str: str, reduced: bool) -> List[Any]:
147147 restli_encoded_str [idx :].startswith (OBJ_PREFIX )
148148 ):
149149 # If we encounter a List or Object as one of the current list's entries, append the decoded value
150- right_bracket_idx = __find_last_right_bracket (restli_encoded_str , idx )
150+ right_bracket_idx = _find_last_right_bracket (restli_encoded_str , idx )
151151 decoded_list .append (
152- __internal_decode (
152+ _internal_decode (
153153 restli_encoded_str [idx : right_bracket_idx + 1 ], reduced
154154 )
155155 )
@@ -162,15 +162,15 @@ def __decode_list(restli_encoded_str: str, reduced: bool) -> List[Any]:
162162 if end_idx < 0 :
163163 end_idx = len (restli_encoded_str )
164164 decoded_list .append (
165- __restli_unescape (restli_encoded_str [idx :end_idx ], reduced )
165+ _restli_unescape (restli_encoded_str [idx :end_idx ], reduced )
166166 )
167167
168168 # Move past the comma
169169 idx = end_idx + 1
170170 return decoded_list
171171
172172
173- def __decode_object (restli_encoded_str : str , reduced : bool ) -> Dict [str , Any ]:
173+ def _decode_object (restli_encoded_str : str , reduced : bool ) -> Dict [str , Any ]:
174174 """
175175 Decodes a Rest.li-encoded string to an object.
176176
@@ -189,7 +189,7 @@ def __decode_object(restli_encoded_str: str, reduced: bool) -> Dict[str, Any]:
189189 while idx < len (restli_encoded_str ):
190190 # Get the key value between the start index and key-val separator (:)
191191 colon_idx = restli_encoded_str .find (OBJ_KEY_VAL_SEP , idx )
192- key = __restli_unescape (restli_encoded_str [idx :colon_idx ], reduced )
192+ key = _restli_unescape (restli_encoded_str [idx :colon_idx ], reduced )
193193
194194 # Move to the next character after the colon
195195 idx = colon_idx + 1
@@ -198,8 +198,8 @@ def __decode_object(restli_encoded_str: str, reduced: bool) -> Dict[str, Any]:
198198 restli_encoded_str [idx :].startswith (OBJ_PREFIX )
199199 ):
200200 # If we encounter a List or Object as the key's value, decode it
201- right_bracket_idx = __find_last_right_bracket (restli_encoded_str , idx )
202- decoded_object [key ] = __internal_decode (
201+ right_bracket_idx = _find_last_right_bracket (restli_encoded_str , idx )
202+ decoded_object [key ] = _internal_decode (
203203 restli_encoded_str [idx : right_bracket_idx + 1 ], reduced
204204 )
205205
@@ -211,7 +211,7 @@ def __decode_object(restli_encoded_str: str, reduced: bool) -> Dict[str, Any]:
211211 if end_idx < 0 :
212212 end_idx = len (restli_encoded_str )
213213
214- decoded_object [key ] = __restli_unescape (
214+ decoded_object [key ] = _restli_unescape (
215215 restli_encoded_str [idx :end_idx ], reduced
216216 )
217217 # end_idx is the comma index, so move 1 past it
0 commit comments