From bba9562e4fd5ac7974aeed66562e63d8467380ab Mon Sep 17 00:00:00 2001 From: pranavgupta1234 Date: Thu, 2 May 2019 12:15:05 +0530 Subject: [PATCH 1/5] added support for .yaml along with .yml --- reclass/storage/yaml_fs/__init__.py | 4 ++-- reclass/storage/yaml_fs/directory.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/reclass/storage/yaml_fs/__init__.py b/reclass/storage/yaml_fs/__init__.py index 20e8eecb..e47ea91a 100644 --- a/reclass/storage/yaml_fs/__init__.py +++ b/reclass/storage/yaml_fs/__init__.py @@ -21,7 +21,7 @@ from reclass.datatypes import Entity import reclass.errors -FILE_EXTENSION = '.yml' +FILE_EXTENSION = ('.yml', '.yaml') STORAGE_NAME = 'yaml_fs' def vvv(msg): @@ -71,7 +71,7 @@ def __init__(self, nodes_uri, classes_uri, compose_node_name): def _enumerate_inventory(self, basedir, name_mangler): ret = {} def register_fn(dirpath, filenames): - filenames = fnmatch.filter(filenames, '*{0}'.format(FILE_EXTENSION)) + filenames = [f for f in filenames if f.endswith(FILE_EXTENSION)] vvv('REGISTER {0} in path {1}'.format(filenames, dirpath)) for f in filenames: name = os.path.splitext(f)[0] diff --git a/reclass/storage/yaml_fs/directory.py b/reclass/storage/yaml_fs/directory.py index a8916b31..4e11643d 100644 --- a/reclass/storage/yaml_fs/directory.py +++ b/reclass/storage/yaml_fs/directory.py @@ -15,7 +15,7 @@ from reclass.errors import NotFoundError SKIPDIRS = ('CVS', 'SCCS') -FILE_EXTENSION = '.yml' +FILE_EXTENSION = ('.yml', '.yaml') def vvv(msg): #print(msg, file=sys.stderr) From 8d17363ca8ebee6d9a67b333969ae6b3b68d395e Mon Sep 17 00:00:00 2001 From: pranavgupta1234 Date: Thu, 2 May 2019 12:27:03 +0530 Subject: [PATCH 2/5] removed fnmatch import --- reclass/storage/yaml_fs/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/reclass/storage/yaml_fs/__init__.py b/reclass/storage/yaml_fs/__init__.py index e47ea91a..3577b362 100644 --- a/reclass/storage/yaml_fs/__init__.py +++ b/reclass/storage/yaml_fs/__init__.py @@ -12,7 +12,6 @@ from __future__ import unicode_literals import os, sys -import fnmatch import yaml from reclass.output.yaml_outputter import ExplicitDumper from reclass.storage import ExternalNodeStorageBase From 8283bfb1a5efbef250bdeac0d7c63184cbc95802 Mon Sep 17 00:00:00 2001 From: pranavgupta1234 Date: Thu, 2 May 2019 21:44:25 +0530 Subject: [PATCH 3/5] extension support added for yaml_git storage as well --- reclass/storage/yaml_git/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reclass/storage/yaml_git/__init__.py b/reclass/storage/yaml_git/__init__.py index a28079b6..78eed048 100644 --- a/reclass/storage/yaml_git/__init__.py +++ b/reclass/storage/yaml_git/__init__.py @@ -34,7 +34,7 @@ from reclass.storage import ExternalNodeStorageBase from reclass.storage.yamldata import YamlData -FILE_EXTENSION = '.yml' +FILE_EXTENSION = ('.yml', '.yaml') STORAGE_NAME = 'yaml_git' def path_mangler(inventory_base_uri, nodes_uri, classes_uri): @@ -213,7 +213,7 @@ def files_in_repo(self): branch = {} files = self.files_in_branch(bname) for file in files: - if fnmatch.fnmatch(file.name, '*{0}'.format(FILE_EXTENSION)): + if str(file.name).endswith(FILE_EXTENSION): name = os.path.splitext(file.name)[0] relpath = os.path.dirname(file.path) if callable(self._class_name_mangler): From 961aa7f06e3f75ac5bd776a9d6e98b5cc769ec41 Mon Sep 17 00:00:00 2001 From: pranavgupta1234 Date: Thu, 2 May 2019 21:55:39 +0530 Subject: [PATCH 4/5] remove import fnmatch from yaml_git as well --- reclass/storage/yaml_git/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/reclass/storage/yaml_git/__init__.py b/reclass/storage/yaml_git/__init__.py index 78eed048..b212b5ef 100644 --- a/reclass/storage/yaml_git/__init__.py +++ b/reclass/storage/yaml_git/__init__.py @@ -11,7 +11,6 @@ import distutils.version import errno import fcntl -import fnmatch import os import time From cc7d59dd816e3020f4024492c6f4392199e06e99 Mon Sep 17 00:00:00 2001 From: pranavgupta1234 Date: Fri, 3 May 2019 07:38:31 +0530 Subject: [PATCH 5/5] removed unnecessary typecasting --- reclass/storage/yaml_git/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reclass/storage/yaml_git/__init__.py b/reclass/storage/yaml_git/__init__.py index b212b5ef..06d839b4 100644 --- a/reclass/storage/yaml_git/__init__.py +++ b/reclass/storage/yaml_git/__init__.py @@ -212,7 +212,7 @@ def files_in_repo(self): branch = {} files = self.files_in_branch(bname) for file in files: - if str(file.name).endswith(FILE_EXTENSION): + if file.name.endswith(FILE_EXTENSION): name = os.path.splitext(file.name)[0] relpath = os.path.dirname(file.path) if callable(self._class_name_mangler):