@@ -358,7 +358,6 @@ def patch_shebang_line(fname, pad=b" ", to_movable=True, targetdir=""):
358358
359359
360360def patch_shebang_line_py (fname , to_movable = True , targetdir = "" ):
361- """Changes shebang line in '.py' file to relative or absolue path"""
362361 """Changes shebang line in '.py' file to relative or absolue path"""
363362 import fileinput
364363 import re
@@ -419,63 +418,6 @@ def patch_sourcefile(fname, in_text, out_text, silent_mode=False):
419418 fh .write (new_content )
420419
421420
422- def patch_sourcelines (
423- fname ,
424- in_line_start ,
425- out_line ,
426- endline = "\n " ,
427- silent_mode = False ,
428- ):
429- """Replace the middle of lines between in_line_start and endline"""
430- import io
431-
432- if Path (fname ).is_file ():
433- the_encoding = guess_encoding (fname )[0 ]
434- with io .open (fname , "r" , encoding = the_encoding ) as fh :
435- contents = fh .readlines ()
436- content = "" .join (contents )
437- for l in range (len (contents )):
438- if contents [l ].startswith (in_line_start ):
439- begining , middle = (
440- in_line_start ,
441- contents [l ][len (in_line_start ) :],
442- )
443- ending = ""
444- if middle .find (endline ) > 0 :
445- ending = endline + endline .join (middle .split (endline )[1 :])
446- middle = middle .split (endline )[0 ]
447- middle = out_line
448- new_line = begining + middle + ending
449- if not new_line == contents [l ]:
450- if not silent_mode :
451- print (
452- "patching " ,
453- fname ,
454- " from\n " ,
455- contents [l ],
456- "\n to\n " ,
457- new_line ,
458- )
459- contents [l ] = new_line
460- new_content = "" .join (contents )
461- if not new_content == content :
462- # if not silent_mode:
463- # print("patching ", fname, "from", content, "to", new_content)
464-
465- with io .open (fname , "wt" , encoding = the_encoding ) as fh :
466- try :
467- fh .write (new_content )
468- except :
469- print (
470- "impossible to patch" ,
471- fname ,
472- "from" ,
473- content ,
474- "to" ,
475- new_content ,
476- )
477-
478-
479421def _create_temp_dir ():
480422 """Create a temporary directory and remove it at exit"""
481423 tmpdir = tempfile .mkdtemp (prefix = 'wppm_' )
0 commit comments