Beispiel #1
0
    def load_from_path(cls):
        Settings.objects.all().delete()

        pelican_settings_name = get_pelican_settings_file()

        pelican_settings = importlib.import_module(pelican_settings_name)
        reload(pelican_settings)

        attr_list = dir(pelican_settings)
        user_settings = dict((attr, getattr(pelican_settings, attr)) for attr in attr_list if not attr.startswith("__"))

        default = dict(ps._DEFAULT_CONFIG.items() + user_settings.items())

        settings_list = []

        for attr, def_value in default.items():
            if not attr.isupper():
                continue

            if isinstance(def_value, str):
                attr_value = def_value
            elif isinstance(def_value, unicode):
                attr_value = unicodedata.normalize("NFKD", def_value).encode("ascii", "ignore")
            else:
                attr_value = pprint.pformat(def_value)

            set = Settings(name=attr, value=attr_value)
            settings_list.append(set)

        Settings.objects.bulk_create(settings_list)
Beispiel #2
0
    def load_from_path(cls):
        Settings.objects.all().delete()

        pelican_settings_name = get_pelican_settings_file()

        pelican_settings = importlib.import_module(pelican_settings_name)
        reload(pelican_settings)

        attr_list = dir(pelican_settings)
        user_settings = dict((attr, getattr(pelican_settings, attr))
                             for attr in attr_list
                             if not attr.startswith('__'))

        default = dict(ps._DEFAULT_CONFIG.items() + user_settings.items())

        settings_list = []

        for attr, def_value in default.items():
            if not attr.isupper(): continue

            if isinstance(def_value, str):
                attr_value = def_value
            elif isinstance(def_value, unicode):
                attr_value = unicodedata.normalize('NFKD', def_value).encode(
                    'ascii', 'ignore')
            else:
                attr_value = pprint.pformat(def_value)

            set = Settings(name=attr, value=attr_value)
            settings_list.append(set)

        Settings.objects.bulk_create(settings_list)
Beispiel #3
0
    def substart():
        pelican_settings_name = get_pelican_settings_file()
        pelican_settings_path = os.path.join(settings.PELICAN_PATH,
                                             pelican_settings_name + '.py')

        pelican_main(settings.PELICAN_PATH,
                     settings=pelican_settings_path,
                     autoreload=True)
Beispiel #4
0
    def write(self):
        pelican_settings_name = get_pelican_settings_file()
        f = open(os.path.join(settings.PELICAN_PATH, pelican_settings_name + ".py"), "w+")

        f.write("#coding: utf-8\n\n")

        all_objs = Settings.objects.all()

        for set in all_objs:
            value = set.value
            try:
                value = ast.literal_eval(value)
            except Exception:
                value = simplejson.dumps(value)

            f.write("%s = %s\n" % (set.name, value))

        f.close()
Beispiel #5
0
    def write(self):
        pelican_settings_name = get_pelican_settings_file()
        f = open(
            os.path.join(settings.PELICAN_PATH, pelican_settings_name + '.py'),
            'w+')

        f.write('#coding: utf-8\n\n')

        all_objs = Settings.objects.all()

        for set in all_objs:
            value = set.value
            try:
                value = ast.literal_eval(value)
            except Exception:
                value = simplejson.dumps(value)

            f.write('%s = %s\n' % (set.name, value))

        f.close()
Beispiel #6
0
    def substart():
        pelican_settings_name = get_pelican_settings_file()
        pelican_settings_path = os.path.join(settings.PELICAN_PATH, pelican_settings_name+'.py')

        pelican_main(settings.PELICAN_PATH, settings=pelican_settings_path, autoreload=True)