mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
backuplocal => backup_local for API standardization reasons
This commit is contained in:
parent
b97e2a6f5a
commit
aa704a6111
4 changed files with 5 additions and 5 deletions
|
@ -276,7 +276,7 @@ class AnsibleModule(object):
|
||||||
infile.close()
|
infile.close()
|
||||||
return digest.hexdigest()
|
return digest.hexdigest()
|
||||||
|
|
||||||
def backuplocal(self, fn):
|
def backup_local(self, fn):
|
||||||
'''make a date-marked backup of the specified file, return True or False on success or failure'''
|
'''make a date-marked backup of the specified file, return True or False on success or failure'''
|
||||||
# backups named basename-YYYY-MM-DD@HH:MM~
|
# backups named basename-YYYY-MM-DD@HH:MM~
|
||||||
ext = time.strftime("%Y-%m-%d@%H:%M~", time.localtime(time.time()))
|
ext = time.strftime("%Y-%m-%d@%H:%M~", time.localtime(time.time()))
|
||||||
|
|
|
@ -75,7 +75,7 @@ def main():
|
||||||
|
|
||||||
if pathmd5 != destmd5:
|
if pathmd5 != destmd5:
|
||||||
if backup and destmd5 is not None:
|
if backup and destmd5 is not None:
|
||||||
module.backuplocal(dest)
|
module.backup_local(dest)
|
||||||
shutil.copy(path, dest)
|
shutil.copy(path, dest)
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ def main():
|
||||||
try:
|
try:
|
||||||
if backup:
|
if backup:
|
||||||
if os.path.exists(dest):
|
if os.path.exists(dest):
|
||||||
backup_file = module.backuplocal(dest)
|
backup_file = module.backup_local(dest)
|
||||||
shutil.copyfile(src, dest)
|
shutil.copyfile(src, dest)
|
||||||
except shutil.Error:
|
except shutil.Error:
|
||||||
module.fail_json(msg="failed to copy: %s and %s are the same" % (src, dest))
|
module.fail_json(msg="failed to copy: %s and %s are the same" % (src, dest))
|
||||||
|
|
|
@ -70,7 +70,7 @@ def present(module, name, regexp, line, insertafter, backup):
|
||||||
|
|
||||||
if changed:
|
if changed:
|
||||||
if backup:
|
if backup:
|
||||||
module.backuplocal(name)
|
module.backup_local(name)
|
||||||
f = open(name, 'wb')
|
f = open(name, 'wb')
|
||||||
f.writelines(lines)
|
f.writelines(lines)
|
||||||
f.close()
|
f.close()
|
||||||
|
@ -93,7 +93,7 @@ def absent(module, name, regexp, backup):
|
||||||
changed = len(found) > 0
|
changed = len(found) > 0
|
||||||
if changed:
|
if changed:
|
||||||
if backup:
|
if backup:
|
||||||
module.backuplocal(name)
|
module.backup_local(name)
|
||||||
f = open(name, 'wb')
|
f = open(name, 'wb')
|
||||||
f.writelines(lines)
|
f.writelines(lines)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
Loading…
Reference in a new issue