MCPcopy Create free account
hub / github.com/AstroPrint/AstroBox / replace

Method replace

src/astroprint/network/debian.py:623–637  ·  view source on GitHub ↗
(file_path, pattern, subst)

Source from the content-addressed store, hash-verified

621
622 if (newName == name):
623 def replace(file_path, pattern, subst):
624 #Create temp file
625 fh, abs_path = mkstemp()
626 new_file = open(abs_path,'w')
627 old_file = open(file_path)
628 for line in old_file:
629 new_file.write(line.replace(pattern, subst))
630 #close temp file
631 new_file.close()
632 close(fh)
633 old_file.close()
634 #Remove original file
635 remove(file_path)
636 #Move new file
637 move(abs_path, file_path)
638
639 udpateFiles = [
640 '/etc/hosts'

Callers 15

_createMovieMethod · 0.80
_getDefaultFolderMethod · 0.80
migrateSettingsFunction · 0.80
installFileMethod · 0.80
get_upload_infoMethod · 0.80
installFileMethod · 0.80
installFileMethod · 0.80
removePluginMethod · 0.80
getFolderContentsMethod · 0.80
setToPlayAndWaitMethod · 0.80
_onBusStateChangedMethod · 0.80
_onRequestStateMethod · 0.80

Calls 2

writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected