@@ -446,12 +446,11 @@ def _read(self, fp: Union[BufferedReader, IO[bytes]], fpname: str) -> None:
446
446
def string_decode (v : str ) -> str :
447
447
if v [- 1 ] == "\\ " :
448
448
v = v [:- 1 ]
449
- # end cut trailing escapes to prevent decode error
449
+ # END cut trailing escapes to prevent decode error
450
450
451
451
return v .encode (defenc ).decode ("unicode_escape" )
452
- # end
453
452
454
- # end
453
+ # END def string_decode
455
454
456
455
while True :
457
456
# We assume to read binary!
@@ -496,12 +495,12 @@ def string_decode(v: str) -> str:
496
495
optval = optval .strip ()
497
496
if optval == '""' :
498
497
optval = ""
499
- # end handle empty string
498
+ # END handle empty string
500
499
optname = self .optionxform (optname .rstrip ())
501
500
if len (optval ) > 1 and optval [0 ] == '"' and optval [- 1 ] != '"' :
502
501
is_multi_line = True
503
502
optval = string_decode (optval [1 :])
504
- # end handle multi-line
503
+ # END handle multi-line
505
504
# Preserves multiple values for duplicate optnames.
506
505
cursect .add (optname , optval )
507
506
else :
@@ -516,7 +515,7 @@ def string_decode(v: str) -> str:
516
515
if line .endswith ('"' ):
517
516
is_multi_line = False
518
517
line = line [:- 1 ]
519
- # end handle quotations
518
+ # END handle quotations
520
519
optval = cursect .getlast (optname )
521
520
cursect .setlast (optname , optval + string_decode (line ))
522
521
# END parse section or option
@@ -600,7 +599,7 @@ def read(self) -> None: # type: ignore[override]
600
599
files_to_read = [self ._file_or_files ]
601
600
else : # for lists or tuples
602
601
files_to_read = list (self ._file_or_files )
603
- # end ensure we have a copy of the paths to handle
602
+ # END ensure we have a copy of the paths to handle
604
603
605
604
seen = set (files_to_read )
606
605
num_read_include_files = 0
@@ -631,27 +630,26 @@ def read(self) -> None: # type: ignore[override]
631
630
if not osp .isabs (include_path ):
632
631
if not file_ok :
633
632
continue
634
- # end ignore relative paths if we don't know the configuration file path
633
+ # END ignore relative paths if we don't know the configuration file path
635
634
file_path = cast (PathLike , file_path )
636
635
assert osp .isabs (file_path ), "Need absolute paths to be sure our cycle checks will work"
637
636
include_path = osp .join (osp .dirname (file_path ), include_path )
638
- # end make include path absolute
637
+ # END make include path absolute
639
638
include_path = osp .normpath (include_path )
640
639
if include_path in seen or not os .access (include_path , os .R_OK ):
641
640
continue
642
641
seen .add (include_path )
643
642
# Insert included file to the top to be considered first.
644
643
files_to_read .insert (0 , include_path )
645
644
num_read_include_files += 1
646
- # each include path in configuration file
647
- # end handle includes
645
+ # END each include path in configuration file
646
+ # END handle includes
648
647
# END for each file object to read
649
648
650
649
# If there was no file included, we can safely write back (potentially) the
651
650
# configuration file without altering its meaning.
652
651
if num_read_include_files == 0 :
653
652
self ._merge_includes = False
654
- # end
655
653
656
654
def _write (self , fp : IO ) -> None :
657
655
"""Write an .ini-format representation of the configuration state in
@@ -714,15 +712,15 @@ def write(self) -> None:
714
712
"Cannot write back if there is not exactly a single file to write to, have %i files"
715
713
% len (self ._file_or_files )
716
714
)
717
- # end assert multiple files
715
+ # END assert multiple files
718
716
719
717
if self ._has_includes ():
720
718
log .debug (
721
719
"Skipping write-back of configuration file as include files were merged in."
722
720
+ "Set merge_includes=False to prevent this."
723
721
)
724
722
return None
725
- # end
723
+ # END stop if we have include files
726
724
727
725
fp = self ._file_or_files
728
726
@@ -904,7 +902,7 @@ def rename_section(self, section: str, new_name: str) -> "GitConfigParser":
904
902
new_section = self ._sections [new_name ]
905
903
for k , vs in self .items_all (section ):
906
904
new_section .setall (k , vs )
907
- # end for each value to copy
905
+ # END for each value to copy
908
906
909
907
# This call writes back the changes, which is why we don't have the respective decorator.
910
908
self .remove_section (section )
0 commit comments