pyguymer3.save_file_if_needed

pyguymer3.save_file_if_needed(fname, fcontent, /, *, debug=True, gitFiles=None, gitMessage='regenerated', gitPath=None, timeout=60.0)[source]

Save a file. If the file already exists, then only overwrite it if the content is different.

Parameters:
  • fname (str) – the file name

  • fcontent (bytes or str) – the file content

  • debug (bool, optional) – print debug messages

  • gitFiles (list of str, optional) – a list of file names known to Git, if the file ends up being saved and the file is not already known to Git then it will be added to Git

  • gitMessage (str, optional) – the Git commit message, if the file ends up being saved and then commit it to Git

  • gitPath (str, optional) – the path to the “git” binary (if not provided then Python will attempt to find the binary itself)

  • timeout (float, optional) – the timeout for any requests/subprocess calls

Returns:

needsSaving – did the file need saving

Return type:

bool

Notes

Copyright 2017 Thomas Guymer [1]

References