1616import fmf .utils as utils
1717from io import open
1818from fmf .utils import log , dict_to_yaml
19+ from fmf .constants import SUFFIX , IGNORED_DIRECTORIES , MAIN
20+ from fmf .plugin_loader import get_suffixes , get_plugin_for_file
1921from pprint import pformat as pretty
2022
21- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22- # Constants
23- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24-
25- SUFFIX = ".fmf"
26- MAIN = "main" + SUFFIX
27- IGNORED_DIRECTORIES = ['/dev' , '/proc' , '/sys' ]
28-
2923# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3024# YAML
3125# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -95,7 +89,6 @@ def __init__(self, data, name=None, parent=None):
9589 # Track whether the data dictionary has been updated
9690 # (needed to prevent removing nodes with an empty dict).
9791 self ._updated = False
98-
9992 # Special handling for top parent
10093 if self .parent is None :
10194 self .name = "/"
@@ -453,7 +446,7 @@ def grow(self, path):
453446 return
454447 # Investigate main.fmf as the first file (for correct inheritance)
455448 filenames = sorted (
456- [filename for filename in filenames if filename .endswith ( SUFFIX )])
449+ [filename for filename in filenames if any ( filter ( filename .endswith , get_suffixes ()) )])
457450 try :
458451 filenames .insert (0 , filenames .pop (filenames .index (MAIN )))
459452 except ValueError :
@@ -465,8 +458,12 @@ def grow(self, path):
465458 fullpath = os .path .abspath (os .path .join (dirpath , filename ))
466459 log .info ("Checking file {0}" .format (fullpath ))
467460 try :
468- with open (fullpath , encoding = 'utf-8' ) as datafile :
469- data = yaml .load (datafile , Loader = YamlLoader )
461+ if fullpath .endswith (SUFFIX ):
462+ with open (fullpath , encoding = 'utf-8' ) as datafile :
463+ data = yaml .load (datafile , Loader = YamlLoader )
464+ else :
465+ plugin = get_plugin_for_file (fullpath )
466+ data = plugin ().get_data (fullpath )
470467 except yaml .error .YAMLError as error :
471468 raise (utils .FileError ("Failed to parse '{0}'.\n {1}" .format (
472469 fullpath , error )))
0 commit comments