Ejemplo n.º 1
0
    def get_directory(self):
        """Retrieves a list of all directives by language"""
        msg = 'Lang\tDirective\tDescription\n'
        for lang in self.languages:
            msg += str(lang) + ' (' + lang.alias + ')\n'
            for dir in lang.directives:
                k = dir.keys()[0]
                skel = skelfactory.create_skel(dir[k])
                dname = '/'.join(k.split('/')[1:])
                if skel.name:
                    msg += '\t' + dname + '\t' + str(skel.name) + '\n'
                    if skel.params:
                        params = ''
                        for p in skel.params:
                            try:
                                params += p[p.keys()[0]] + ' '
                            except:
                                params += p + ' '
                        msg += '\targuments: ' + params + '\n\n'

        return msg
Ejemplo n.º 2
0
    def load_directives(self, directory):
        """loads directives recursively from a directory"""
        log.debug('loading directives...')
        for path, dirs, files in os.walk(directory):
            for type_ in skelfactory.SKEL_TYPES:
                type_ = 'skel.' + type_
                if type_ in files:
                    log.debug('found file: ' + type_)
                    skel_file = os.path.join(path, type_)
                    s = skelfactory.create_skel(skel_file)

                    log.debug(
                        'Loading directive: '
                        + str(s.directive)
                        + ' into language '
                        + str(s.language)
                        + ' from file: '
                        + '"' + skel_file + '"'
                    )

                    lang = self.lang(s.language)
                    if lang:
                        lang.add_directive(s.directive, skel_file)