Пример #1
0
 def __init__(self, params):
     framework.Framework.__init__(self, params)
     self.options = framework.Options()
     # update the meta dictionary by merging the class variable with any frontmatter
     self.meta = self._merge_dicts(self.meta, self._parse_frontmatter())
     # register a data source option if a default query is specified in the module
     if self.meta.get('query'):
         self._default_source = self.meta.get('query')
         self.register_option('source', 'default', True, 'source of input (see \'info\' for details)')
     # register all other specified options
     if self.meta.get('options'):
         for option in self.meta.get('options'):
             self.register_option(*option)
     # register any required keys
     if self.meta.get('required_keys'):
         self.keys = {}
         for key in self.meta.get('required_keys'):
             # add key to the database
             self._query_keys('INSERT OR IGNORE INTO keys (name) VALUES (?)', (key,))
             # migrate the old key if needed
             self._migrate_key(key)
             # add key to local keys dictionary
             # could fail to load on exception here to prevent loading modules
             # without required keys, but would need to do it in a separate loop
             # so that all keys get added to the database first. for now, the
             # framework will warn users of the missing key, but allow the module
             # to load.
             self.keys[key] = self.get_key(key)
             if not self.keys.get(key):
                 self.error(f"'{key}' key not set. {self._modulename.split('/')[-1]} module will likely fail at runtime. See 'keys add'.")
     self._reload = 0
Пример #2
0
 def __init__(self, params, query=None):
     framework.Framework.__init__(self, params)
     self.options = framework.Options()
     # register a data source option if a default query is specified in the module
     if 'query' in self.meta:
         self._default_source = self.meta['query']
         self.register_option(
             'source', 'default', True,
             'source of input (see \'show info\' for details)')
     # register all other specified options
     if 'options' in self.meta:
         for option in self.meta['options']:
             self.register_option(*option)
     self._reload = 0
Пример #3
0
    def __init__(self, params, query=None):
        self.logger.debug('')
        framework.Framework.__init__(self, params)
        self.options = framework.Options()
        self.module_path = os.path.join(self.app_path, 'modules',
                                        "%s.py" % self._modulename)

        if 'query' in self.meta:
            self._default_source = self.meta['query']
            self.register_option(
                'source', 'default', True,
                'source of input (see \'show info\' for details)')

        # register all other specified options
        if 'options' in self.meta:
            for option in self.meta['options']:
                self.register_option(*option)

        self._reload = 0