Merge pull request #85 from pranavgupta1234/extend_file_extension
added support for .yaml along with .yml
diff --git a/reclass/storage/yaml_fs/__init__.py b/reclass/storage/yaml_fs/__init__.py
index 20e8eec..3577b36 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
@@ -21,7 +20,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 +70,7 @@
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 a8916b3..4e11643 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)
diff --git a/reclass/storage/yaml_git/__init__.py b/reclass/storage/yaml_git/__init__.py
index a28079b..06d839b 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
@@ -34,7 +33,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 +212,7 @@
branch = {}
files = self.files_in_branch(bname)
for file in files:
- if fnmatch.fnmatch(file.name, '*{0}'.format(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):