From 00ebd0c89d56e5b6c1885d5346bf9f9da0f2f234 Mon Sep 17 00:00:00 2001 From: Sloane Hertel Date: Sun, 23 Apr 2017 03:19:22 -0400 Subject: [PATCH] make lineinfile docs clearer and make module pep8 (#23857) --- lib/ansible/modules/files/lineinfile.py | 7 ++++--- test/sanity/pep8/legacy-files.txt | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/files/lineinfile.py b/lib/ansible/modules/files/lineinfile.py index db46762f0f..4a2444c378 100644 --- a/lib/ansible/modules/files/lineinfile.py +++ b/lib/ansible/modules/files/lineinfile.py @@ -55,7 +55,7 @@ options: description: - The regular expression to look for in every line of the file. For C(state=present), the pattern to replace if found; only the last line - found will be replaced. For C(state=absent), the pattern of the line + found will be replaced. For C(state=absent), the pattern of the line(s) to remove. Uses Python regular expressions; see U(http://docs.python.org/2/library/re.html). state: @@ -216,8 +216,8 @@ def write_changes(module, b_lines, dest): 'rc:%s error:%s' % (rc, err)) if valid: module.atomic_move(tmpfile, - to_native(os.path.realpath(to_bytes(dest, errors='surrogate_or_strict')), errors='surrogate_or_strict'), - unsafe_writes=module.params['unsafe_writes']) + to_native(os.path.realpath(to_bytes(dest, errors='surrogate_or_strict')), errors='surrogate_or_strict'), + unsafe_writes=module.params['unsafe_writes']) def check_file_attrs(module, changed, message, diff): @@ -379,6 +379,7 @@ def absent(module, dest, regexp, line, backup): found = [] b_line = to_bytes(line, errors='surrogate_or_strict') + def matcher(b_cur_line): if regexp is not None: match_found = bre_c.search(b_cur_line) diff --git a/test/sanity/pep8/legacy-files.txt b/test/sanity/pep8/legacy-files.txt index 85d23ddd97..91885c3383 100644 --- a/test/sanity/pep8/legacy-files.txt +++ b/test/sanity/pep8/legacy-files.txt @@ -418,7 +418,6 @@ lib/ansible/modules/files/copy.py lib/ansible/modules/files/find.py lib/ansible/modules/files/ini_file.py lib/ansible/modules/files/iso_extract.py -lib/ansible/modules/files/lineinfile.py lib/ansible/modules/files/patch.py lib/ansible/modules/files/replace.py lib/ansible/modules/files/stat.py