class globs

Matthew Williams mgwilliams at gmail.com
Wed Oct 16 04:05:19 CEST 2013


I'm interested in a feature that adds globbing for class paths.

E.g.:

classes:
  locations/*/networks/*

In this case, locations has several location directories, and each location
also has several yml files in the networks directory. This would be a
shortcut for including/merging all those network files, when needed. This
of course is just an example, I imagine there could be any number of
similar use cases.

I was thinking of something like this, in storage/yaml_fs/__init__.py

     def _read_nodeinfo(self, name, base_uri, seen, nodename=None):
         path = os.path.join(base_uri, name + FILE_EXTENSION)
+        paths = glob.glob(path)
+        if len(paths) > 1:
+            merge_base = Entity()
+            for f in paths:
+                f = f.replace(base_uri, '', 1).lstrip('/')
+                f = f[:f.rfind(FILE_EXTENSION)]
+                ret = self._read_nodeinfo(f, base_uri, seen,
+                                          name if nodename is None else
nodename)[0]
+                merge_base.merge(ret)
+            return merge_base, path
+        else:

Is this a good or a bad idea?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pantsfullofunix.net/pipermail/reclass/attachments/20131015/e1ff28aa/attachment.html>


More information about the reclass mailing list