Esempio n. 1
0
    def get(self):
        from kandu import patterns as p
        self.engine.hierarchy = p.set_repository(
            json.load(open(self.engine.jsonfile)), self.engine.repository)

        html = self.get_preview_section()
        h = self.hierarchy_to_html()
        self.render("html/index.html", repository=html, hierarchy=h)
Esempio n. 2
0
    def post(self):
        from kandu import patterns as p
        preset = self.get_argument('p')
        if preset == 'loadopenfmri':
            self.engine.hierarchy.update(
                p.set_repository(p.openfmri, self.engine.repository))
        elif preset == 'loadjson':
            print self.engine.jsonfile
            self.engine.hierarchy.update(
                p.set_repository(json.load(open(self.engine.jsonfile)),
                                 self.engine.repository))
        elif preset == 'loadfreesurfer':
            self.engine.hierarchy.update(
                p.set_repository(p.freesurfer, self.engine.repository))
        elif preset == 'loadmorpho':
            self.engine.hierarchy.update(
                p.set_repository(p.morphologist, self.engine.repository))
        elif preset == 'reset':
            self.engine.hierarchy = {}

        html = self.hierarchy_to_html()
        self.write(html)
Esempio n. 3
0
    def get(self):
        from kandu import patterns as p
        self.engine.hierarchy = p.set_repository(
            json.load(open(self.engine.jsonfile)), self.engine.repository)

        html = self.get_preview_section()
        h = self.hierarchy_to_html()
        html = self.render_string("html/index.html",
                                  repository=html,
                                  hierarchy=h)
        html = html.replace(
            '<script id="tests"></script>',
            '<script>%s</script>' % self.render_string('js/tests.js'))
        self.write(html)
Esempio n. 4
0
    def __init__(self, repository, jsonfile, ignorelist=[], maxitems = 500, unknown_only=False, separators='_'):
        self.repository = osp.abspath(repository)
        self.jsonfile = osp.abspath(jsonfile)
        if osp.isfile(self.jsonfile):
            j = p.set_repository(json.load(open(self.jsonfile)), self.repository)
        else:
            j = {}
            print 'Creating %s'%self.jsonfile
            json.dump(p.strip_repository(j, self.repository), open(self.jsonfile, 'w'))
        self.hierarchy = j
        self.maxitems = maxitems
        self.ignorelist = ignorelist
        self.unknown_only = unknown_only

        allowed_sep = set('_.-')
        removed_sep = list(set(separators).difference(allowed_sep))
        if len(removed_sep) != 0:
           print 'The following separators have been ignored : %s'%', '.join(removed_sep)
        kept_sep = list(set(separators).intersection(allowed_sep))
        if len(kept_sep) == 0:
           raise Exception('no valid separators given in %s (allowed : %s)'%(separators, ' '.join(allowed_sep)))

        self.separators = kept_sep
        self.separators.append('/')
Esempio n. 5
0
 def __init__(self, repository, rules):
     self.repository = repository.rstrip('/')
     self.rules = p.set_repository(rules, repository)