In short,I've written an application that parses text files in specified formats from different email feeds. Currently, there are two formats allowed by users in order to correctly upload information. I've also included a simple YAML file that allows people with non-programming backgrounds (ie sysadmins) to define the basics parsing parameters such as delimiters for each different email feed.
As it turns out, users are going to require a lot more formats than the ones I've defined. As in entirely-different-parsing-algorithm format.
Since it would be difficult for someone not familiar with the source to constantly add/update parsing methods, my idea is to allow the admin to define custom methods in the YAML file like so:
parser: !!python/name:modules.custom.parse开发者_Go百科r
That way the admin can define their own parsing method called, for example, modules.custom.parser without having to dig through source code.
Am I playing with fire allowing the admin to dynamically upload their own custom methods?
I don't think the idea of having "executable config files" is a bad one, but I think having a mix of YAML and Python code could be confusing. Perhaps instead you could go the route of Xen, SCons, hellanzb, etc. and have your "config file" just be a Python script?
精彩评论