From c4e712ba3cc40d1deed87f56c71b337193597422 Mon Sep 17 00:00:00 2001 From: Kenny Woodson Date: Thu, 16 Feb 2017 16:53:14 -0500 Subject: Pleasing the linting gods. --- roles/lib_utils/library/repoquery.py | 2 +- roles/lib_utils/library/yedit.py | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) (limited to 'roles/lib_utils/library') diff --git a/roles/lib_utils/library/repoquery.py b/roles/lib_utils/library/repoquery.py index 235518e9d..cc7aa04fd 100644 --- a/roles/lib_utils/library/repoquery.py +++ b/roles/lib_utils/library/repoquery.py @@ -39,7 +39,7 @@ 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 diff --git a/roles/lib_utils/library/yedit.py b/roles/lib_utils/library/yedit.py index 7f71e6cbc..a358e980e 100644 --- a/roles/lib_utils/library/yedit.py +++ b/roles/lib_utils/library/yedit.py @@ -39,7 +39,7 @@ 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 @@ -380,12 +380,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)) @@ -428,13 +428,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: @@ -600,6 +603,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) @@ -624,8 +628,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() -- cgit v1.2.3