aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCedric Ollivier <cedric.ollivier@orange.com>2020-03-16 11:55:37 +0000
committerGerrit Code Review <gerrit@opnfv.org>2020-03-16 11:55:37 +0000
commit004298391e45dee9421748bc1312cda5d2af2d43 (patch)
tree5bff81716944c11e6be8f63a794b5188084449b5
parent0f663f5ce102f2d91c2aa6a8bfb6c2ef13d8ba7d (diff)
parentb2ee1e349dc898aed861a5c7f31d86b83e6fe1be (diff)
Merge "FLAKE8: Fixes to SDV python files."
-rwxr-xr-xtools/sdv/NwLinksValid/__init__.py1
-rw-r--r--tools/sdv/NwLinksValid/nwlinksvalidator.py1
-rwxr-xr-xtools/sdv/SoftwarePostValid/__init__.py1
-rw-r--r--tools/sdv/SoftwarePostValid/swpostvalidator.py1
-rwxr-xr-xtools/sdv/SoftwarePreValid/__init__.py1
-rw-r--r--tools/sdv/SoftwarePreValid/airship.py20
-rw-r--r--tools/sdv/SoftwarePreValid/swprevalidator.py1
-rw-r--r--tools/sdv/conf/__init__.py24
-rw-r--r--tools/sdv/core/__init__.py2
-rw-r--r--tools/sdv/core/component_factory.py1
-rw-r--r--tools/sdv/core/loader/__init__.py2
-rw-r--r--tools/sdv/core/loader/loader.py1
-rw-r--r--tools/sdv/core/loader/loader_servant.py1
-rw-r--r--yamllintrc25
14 files changed, 64 insertions, 18 deletions
diff --git a/tools/sdv/NwLinksValid/__init__.py b/tools/sdv/NwLinksValid/__init__.py
index 87b6e58..99456db 100755
--- a/tools/sdv/NwLinksValid/__init__.py
+++ b/tools/sdv/NwLinksValid/__init__.py
@@ -13,4 +13,5 @@
"""Nework-Links Validator interface and helpers.
"""
+# flake8: noqa
from NwLinksValid.nwlinksvalidator import *
diff --git a/tools/sdv/NwLinksValid/nwlinksvalidator.py b/tools/sdv/NwLinksValid/nwlinksvalidator.py
index 3b84595..5e06590 100644
--- a/tools/sdv/NwLinksValid/nwlinksvalidator.py
+++ b/tools/sdv/NwLinksValid/nwlinksvalidator.py
@@ -17,6 +17,7 @@ Abstract class for N/W Lnks Prevalidations.
Implementors, please inherit from this class.
"""
+
class INwLinksValidator():
""" Model for a Links Validator """
def __init__(self):
diff --git a/tools/sdv/SoftwarePostValid/__init__.py b/tools/sdv/SoftwarePostValid/__init__.py
index 1c6f121..0a964b6 100755
--- a/tools/sdv/SoftwarePostValid/__init__.py
+++ b/tools/sdv/SoftwarePostValid/__init__.py
@@ -15,4 +15,5 @@
"""Sw Validator interface and helpers.
"""
+# flake8: noqa
from SoftwarePostValid.swpostvalidator import *
diff --git a/tools/sdv/SoftwarePostValid/swpostvalidator.py b/tools/sdv/SoftwarePostValid/swpostvalidator.py
index 2901cd4..4776123 100644
--- a/tools/sdv/SoftwarePostValid/swpostvalidator.py
+++ b/tools/sdv/SoftwarePostValid/swpostvalidator.py
@@ -17,6 +17,7 @@ Abstract class for Software Postvalidations.
Implementors, please inherit from this class.
"""
+
class ISwPostValidator():
""" Model for a Sw Validator """
def __init__(self):
diff --git a/tools/sdv/SoftwarePreValid/__init__.py b/tools/sdv/SoftwarePreValid/__init__.py
index e29c0af..8307b66 100755
--- a/tools/sdv/SoftwarePreValid/__init__.py
+++ b/tools/sdv/SoftwarePreValid/__init__.py
@@ -15,4 +15,5 @@
"""Sw Validator interface and helpers.
"""
+# flake8: noqa
from SoftwarePreValid.swprevalidator import *
diff --git a/tools/sdv/SoftwarePreValid/airship.py b/tools/sdv/SoftwarePreValid/airship.py
index 902b654..bd93aa2 100644
--- a/tools/sdv/SoftwarePreValid/airship.py
+++ b/tools/sdv/SoftwarePreValid/airship.py
@@ -25,6 +25,7 @@ import yaml
from conf import settings
from SoftwarePreValid import swprevalidator
+
def check_link(link):
"""
Function the check the availability of Hyperlinks
@@ -53,6 +54,7 @@ def check_link(link):
return False
return True
+
class Airship(swprevalidator.ISwPreValidator):
"""
Ariship Sw Validation
@@ -119,8 +121,6 @@ class Airship(swprevalidator.ISwPreValidator):
else:
print("The Link: %s is INVALID" % (location))
-
-
# pylint: disable=consider-using-enumerate
def find_locations(self, yamlfile):
"""
@@ -174,16 +174,16 @@ class Airship(swprevalidator.ISwPreValidator):
'maas.yaml')
with open(os_filename, 'r') as osref:
osfiles = yaml.load_all(osref, Loader=yaml.FullLoader)
- for osfile in osfiles:
- if ('data' in osfile and
- 'values' in osfile['data'] and
- 'conf' in osfile['data']['values'] and
- 'maas' in osfile['data']['values']['conf'] and
- 'images' in osfile['data']['values']['conf']['maas'] and
+ for osf in osfiles:
+ if ('data' in osf and
+ 'values' in osf['data'] and
+ 'conf' in osf['data']['values'] and
+ 'maas' in osf['data']['values']['conf'] and
+ 'images' in osf['data']['values']['conf']['maas'] and
('default_os' in
- osfile['data']['values']['conf']['maas']['images'])):
+ osf['data']['values']['conf']['maas']['images'])):
if (settings.getValue('OPERATING_SYSTEM') in
- osfile['data']['values']['conf']['maas']['images'][
+ osf['data']['values']['conf']['maas']['images'][
'default_os']):
print('Operating System is VALID')
os_done = True
diff --git a/tools/sdv/SoftwarePreValid/swprevalidator.py b/tools/sdv/SoftwarePreValid/swprevalidator.py
index 485fc2b..bef141b 100644
--- a/tools/sdv/SoftwarePreValid/swprevalidator.py
+++ b/tools/sdv/SoftwarePreValid/swprevalidator.py
@@ -17,6 +17,7 @@ Abstract class for Software Prevalidations.
Implementors, please inherit from this class.
"""
+
class ISwPreValidator():
""" Model for a Sw Validator """
def __init__(self):
diff --git a/tools/sdv/conf/__init__.py b/tools/sdv/conf/__init__.py
index 4e68c70..ef97aa7 100644
--- a/tools/sdv/conf/__init__.py
+++ b/tools/sdv/conf/__init__.py
@@ -25,8 +25,6 @@ import os
import re
import logging
import pprint
-import ast
-import netaddr
_LOGGER = logging.getLogger(__name__)
@@ -40,6 +38,7 @@ _LOGGER = logging.getLogger(__name__)
# #EVAL(2*#VMINDEX)
_PARSE_PATTERN = r'(#[A-Z]+)(\(([^(),]+)(,([0-9]+))?\))?'
+
class Settings(object):
"""Holding class for settings.
"""
@@ -52,15 +51,22 @@ class Settings(object):
"""
if isinstance(param, str):
# evaluate every #PARAM reference inside parameter itself
- macros = re.findall(r'#PARAM\((([\w\-]+)(\[[\w\[\]\-\'\"]+\])*)\)', param)
+ macros = re.findall(
+ r'#PARAM\((([\w\-]+)(\[[\w\[\]\-\'\"]+\])*)\)',
+ param)
if macros:
for macro in macros:
# pylint: disable=eval-used
try:
- tmp_val = str(eval("self.getValue('{}'){}".format(macro[1], macro[2])))
- param = param.replace('#PARAM({})'.format(macro[0]), tmp_val)
- # silently ignore that option required by PARAM macro can't be evaluated;
- # It is possible, that referred parameter will be constructed during runtime
+ tmp_val = str(
+ eval("self.getValue('{}'){}".format(macro[1],
+ macro[2])))
+ param = param.replace('#PARAM({})'.format(macro[0]),
+ tmp_val)
+ # silently ignore that option required by
+ # PARAM macro can't be evaluated;
+ # It is possible, that referred parameter
+ # will be constructed during runtime
# and re-read later.
except IndexError:
pass
@@ -133,7 +139,8 @@ class Settings(object):
:returns: None
"""
- regex = re.compile("^(?P<digit_part>[0-9]+)(?P<alfa_part>[a-z]?)_.*.conf$")
+ regex = re.compile(
+ "^(?P<digit_part>[0-9]+)(?P<alfa_part>[a-z]?)_.*.conf$")
def get_prefix(filename):
"""
@@ -224,6 +231,7 @@ class Settings(object):
assert value == self.__dict__[name]
return True
+
settings = Settings()
diff --git a/tools/sdv/core/__init__.py b/tools/sdv/core/__init__.py
index 6c1db43..2441d38 100644
--- a/tools/sdv/core/__init__.py
+++ b/tools/sdv/core/__init__.py
@@ -14,4 +14,6 @@
"""Core structural interfaces and their implementations
"""
+
+# flake8: noqa
import core.component_factory
diff --git a/tools/sdv/core/component_factory.py b/tools/sdv/core/component_factory.py
index 68ad460..396aa28 100644
--- a/tools/sdv/core/component_factory.py
+++ b/tools/sdv/core/component_factory.py
@@ -16,6 +16,7 @@
Create Components.
"""
+
def create_swprevalidator(swprevalidator_class):
""" Create Pre-Validators"""
return swprevalidator_class()
diff --git a/tools/sdv/core/loader/__init__.py b/tools/sdv/core/loader/__init__.py
index c3b60a4..e86c48e 100644
--- a/tools/sdv/core/loader/__init__.py
+++ b/tools/sdv/core/loader/__init__.py
@@ -13,4 +13,6 @@
"""
Core: Loader Component.
"""
+
+# flake8: noqa
from .loader import Loader
diff --git a/tools/sdv/core/loader/loader.py b/tools/sdv/core/loader/loader.py
index ea62d0c..c9f8e96 100644
--- a/tools/sdv/core/loader/loader.py
+++ b/tools/sdv/core/loader/loader.py
@@ -23,6 +23,7 @@ from SoftwarePreValid.swprevalidator import ISwPreValidator
from SoftwarePostValid.swpostvalidator import ISwPostValidator
from NwLinksValid.nwlinksvalidator import INwLinksValidator
+
# pylint: disable=too-many-public-methods
class Loader():
"""Loader class - main object context holder.
diff --git a/tools/sdv/core/loader/loader_servant.py b/tools/sdv/core/loader/loader_servant.py
index ba175d5..4e55c67 100644
--- a/tools/sdv/core/loader/loader_servant.py
+++ b/tools/sdv/core/loader/loader_servant.py
@@ -23,6 +23,7 @@ import fnmatch
import logging
from conf import settings
+
class LoaderServant():
"""Class implements basic dynamic import operations.
"""
diff --git a/yamllintrc b/yamllintrc
new file mode 100644
index 0000000..bb11492
--- /dev/null
+++ b/yamllintrc
@@ -0,0 +1,25 @@
+# Copyright 2020 Tieto
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+extends: relaxed
+
+rules:
+ empty-lines:
+ max-start: 1
+ max-end: 1
+ colons:
+ max-spaces-after: 1
+ max-spaces-before: 1
+ line-length:
+ max: 160