mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-06 22:24:23 -07:00
Blanks Again
This commit is contained in:
parent
bccf55ba98
commit
4f4c4bda34
1 changed files with 6 additions and 12 deletions
|
@ -70,12 +70,12 @@ import hashlib
|
||||||
|
|
||||||
|
|
||||||
def get_exports(module, output_format, file_path="/etc/exports"):
|
def get_exports(module, output_format, file_path="/etc/exports"):
|
||||||
|
|
||||||
IP_ENTRY_PATTERN = re.compile(r'(\d+\.\d+\.\d+\.\d+)\(([^)]+)\)')
|
IP_ENTRY_PATTERN = re.compile(r'(\d+\.\d+\.\d+\.\d+)\(([^)]+)\)')
|
||||||
MAIN_LINE_PATTERN = re.compile(r'\s*(\S+)\s+(.+)')
|
MAIN_LINE_PATTERN = re.compile(r'\s*(\S+)\s+(.+)')
|
||||||
|
|
||||||
file_digests = {}
|
file_digests = {}
|
||||||
hash_algorithms = ['sha256', 'sha1', 'md5']
|
hash_algorithms = ['sha256', 'sha1', 'md5']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ def get_exports(module, output_format, file_path="/etc/exports"):
|
||||||
|
|
||||||
file_content_bytes = None
|
file_content_bytes = None
|
||||||
try:
|
try:
|
||||||
with open(file_path, 'rb') as f: # Open in binary mode for hashing
|
with open(file_path, 'rb') as f:
|
||||||
file_content_bytes = f.read()
|
file_content_bytes = f.read()
|
||||||
except IOError:
|
except IOError:
|
||||||
module.fail_json(msg="Could not read {}".format(file_path))
|
module.fail_json(msg="Could not read {}".format(file_path))
|
||||||
|
@ -99,21 +99,15 @@ def get_exports(module, output_format, file_path="/etc/exports"):
|
||||||
module.warn("Hash algorithm '{}' not available on this system. Skipping.".format(algo))
|
module.warn("Hash algorithm '{}' not available on this system. Skipping.".format(algo))
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
module.warn("Error calculating '{}' hash: {}".format(algo, ex))
|
module.warn("Error calculating '{}' hash: {}".format(algo, ex))
|
||||||
|
exports = {}
|
||||||
|
|
||||||
exports = {}
|
|
||||||
|
|
||||||
output_lines = []
|
output_lines = []
|
||||||
if file_content_bytes:
|
if file_content_bytes:
|
||||||
output_lines = file_content_bytes.decode('utf-8', errors='ignore').splitlines()
|
output_lines = file_content_bytes.decode('utf-8', errors='ignore').splitlines()
|
||||||
|
|
||||||
|
|
||||||
for line in output_lines:
|
for line in output_lines:
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if not line or line.startswith('#'):
|
if not line or line.startswith('#'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
match = MAIN_LINE_PATTERN.match(line)
|
match = MAIN_LINE_PATTERN.match(line)
|
||||||
if not match:
|
if not match:
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue