Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for .yaml along with .yml #85

Merged
merged 5 commits into from
Jun 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions reclass/storage/yaml_fs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -71,7 +70,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]
Expand Down
2 changes: 1 addition & 1 deletion reclass/storage/yaml_fs/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions reclass/storage/yaml_git/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import distutils.version
import errno
import fcntl
import fnmatch
import os
import time

Expand All @@ -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):
Expand Down Expand Up @@ -213,7 +212,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 file.name.endswith(FILE_EXTENSION):
name = os.path.splitext(file.name)[0]
relpath = os.path.dirname(file.path)
if callable(self._class_name_mangler):
Expand Down