Example #1
0
 def run(self, args, options):
     settings = self.engine.settings
     if options.get:
         print settings.get(options.get)
     elif options.getbool:
         print settings.get_bool(options.getbool)
     elif options.getint:
         print settings.get_int(options.getint)
     elif options.getfloat:
         print settings.get_float(options.getfloat)
     elif options.getlist:
         print settings.get_list(options.getlist)
     else:
         special_dicts = ['PIPELINE', 'EXTENSIONS']
         for key in sorted(settings.keys()):
             if key in special_dicts:
                 d = settings.get(key + '_BASE')
                 d.update(settings.get(key))
                 value = [(k, v)
                          for k, v in sorted(d.items(), key=itemgetter(1))
                          if v is not None]
             elif cut_suffix(key, '_BASE') in special_dicts:
                 continue
             else:
                 value = settings.get(key)
             print '%s: %s' % (key, pformat(value))
Example #2
0
def render_templatefile(path, **kwargs):
    with open(path, 'rb') as file:
        raw = file.read()

    content = string.Template(raw).substitute(**kwargs)

    with open(cut_suffix(path, '.tmpl'), 'wb') as file:
        file.write(content)
    if path.endswith('.tmpl'):
        os.remove(path)
Example #3
0
 def run(self, args, options):
     settings = self.engine.settings
     if options.get:
         print settings.get(options.get)
     elif options.getbool:
         print settings.get_bool(options.getbool)
     elif options.getint:
         print settings.get_int(options.getint)
     elif options.getfloat:
         print settings.get_float(options.getfloat)
     elif options.getlist:
         print settings.get_list(options.getlist)
     else:
         special_dicts = ["PIPELINE", "EXTENSIONS"]
         for key in sorted(settings.keys()):
             if key in special_dicts:
                 d = settings.get(key + "_BASE")
                 d.update(settings.get(key))
                 value = [(k, v) for k, v in sorted(d.items(), key=itemgetter(1)) if v is not None]
             elif cut_suffix(key, "_BASE") in special_dicts:
                 continue
             else:
                 value = settings.get(key)
             print "%s: %s" % (key, pformat(value))
 def test_cut_suffix(self):
     self.assertEqual(cut_suffix('helloworld', 'world'), 'hello')
     self.assertEqual(cut_suffix('helloworld', 'worldx'), 'helloworld')
     self.assertEqual(cut_suffix('helloworld', 'xworld'), 'helloworld')
     self.assertEqual(cut_suffix('aaaaaa', 'a'), 'aaaaa')
     self.assertEqual(cut_suffix('aaa', 'aaaa'), 'aaa')
Example #5
0
 def test_cut_suffix(self):
     self.assertEqual(cut_suffix('helloworld', 'world'), 'hello')
     self.assertEqual(cut_suffix('helloworld', 'worldx'), 'helloworld')
     self.assertEqual(cut_suffix('helloworld', 'xworld'), 'helloworld')
     self.assertEqual(cut_suffix('aaaaaa', 'a'), 'aaaaa')
     self.assertEqual(cut_suffix('aaa', 'aaaa'), 'aaa')