diff options
Diffstat (limited to 'roles/lib_utils/src')
-rw-r--r-- | roles/lib_utils/src/class/yedit.py | 16 | ||||
-rw-r--r-- | roles/lib_utils/src/lib/import.py | 2 |
2 files changed, 12 insertions, 6 deletions
diff --git a/roles/lib_utils/src/class/yedit.py b/roles/lib_utils/src/class/yedit.py index cecc1ed4f..5275e84eb 100644 --- a/roles/lib_utils/src/class/yedit.py +++ b/roles/lib_utils/src/class/yedit.py @@ -194,12 +194,12 @@ class Yedit(object): if self.backup and self.file_exists(): shutil.copy(self.filename, self.filename + '.orig') - # pylint: disable=no-member - if hasattr(self.yaml_dict, 'fa'): - self.yaml_dict.fa.set_block_style() - - # pylint: disable=no-member if hasattr(yaml, 'RoundTripDumper'): + # pylint: disable=no-member + if hasattr(self.yaml_dict, 'fa'): + self.yaml_dict.fa.set_block_style() + + # pylint: disable=no-member Yedit._write(self.filename, yaml.dump(self.yaml_dict, Dumper=yaml.RoundTripDumper)) else: Yedit._write(self.filename, yaml.safe_dump(self.yaml_dict, default_flow_style=False)) @@ -242,13 +242,16 @@ class Yedit(object): # check if it is yaml try: if content_type == 'yaml' and contents: + # pylint: disable=no-member if hasattr(yaml, 'RoundTripLoader'): self.yaml_dict = yaml.load(contents, yaml.RoundTripLoader) else: self.yaml_dict = yaml.safe_load(contents) + # pylint: disable=no-member if hasattr(self.yaml_dict, 'fa'): self.yaml_dict.fa.set_block_style() + elif content_type == 'json' and contents: self.yaml_dict = json.loads(contents) except yaml.YAMLError as err: @@ -414,6 +417,7 @@ class Yedit(object): # deepcopy didn't work if hasattr(yaml, 'round_trip_dump'): + # pylint: disable=no-member tmp_copy = yaml.load(yaml.round_trip_dump(self.yaml_dict, default_flow_style=False), yaml.RoundTripLoader) @@ -438,8 +442,10 @@ class Yedit(object): if not self.file_exists(): # deepcopy didn't work if hasattr(yaml, 'round_trip_dump'): + # pylint: disable=no-member tmp_copy = yaml.load(yaml.round_trip_dump(self.yaml_dict, default_flow_style=False), # noqa: E501 yaml.RoundTripLoader) + # pylint: disable=no-member if hasattr(self.yaml_dict, 'fa'): tmp_copy.fa.set_block_style() diff --git a/roles/lib_utils/src/lib/import.py b/roles/lib_utils/src/lib/import.py index ea9fb8ce5..ed57a68c9 100644 --- a/roles/lib_utils/src/lib/import.py +++ b/roles/lib_utils/src/lib/import.py @@ -14,6 +14,6 @@ import shutil # noqa: F401 try: import ruamel.yaml as yaml # noqa: F401 except ImportError: - import yaml + import yaml # noqa: F401 from ansible.module_utils.basic import AnsibleModule |