예제 #1
0
def read_settings(filename):
    """Load a Python file into a dictionary.
    """
    context = _DEFAULT_CONFIG.copy()
    if filename:
        tempdict = {}
        execfile(filename, tempdict)
        for key in tempdict:
            if key.isupper():
                context[key] = tempdict[key]

    # if locales is not a list, make it one
    locales = context['LOCALE']

    if isinstance(locales, basestring):
        locales = [locales]

    # try to set the different locales, fallback on the default.
    if not locales:
        locales = _DEFAULT_CONFIG['LOCALE']

    for locale_ in locales:
        try:
            locale.setlocale(locale.LC_ALL, locale_)
            break # break if it is successfull
        except locale.Error:
            pass
    else:
        log.warn("LOCALE option doesn't contain a correct value")

    # set the locale
    return context
예제 #2
0
파일: settings.py 프로젝트: ramxpa/pelican
def read_settings(filename):
    """Load a Python file into a dictionary.
    """
    context = _DEFAULT_CONFIG.copy()
    if filename:
        tempdict = {}
        execfile(filename, tempdict)
        for key in tempdict:
            if key.isupper():
                context[key] = tempdict[key]

        # Make the paths relative to the settings file
        for path in ['PATH', 'OUTPUT_PATH']:
            if path in context:
                if context[path] is not None and not os.path.isabs(
                        context[path]):
                    # FIXME:
                    context[path] = os.path.abspath(
                        os.path.normpath(
                            os.path.join(os.path.dirname(filename),
                                         context[path])))

    # if locales is not a list, make it one
    locales = context['LOCALE']

    if isinstance(locales, basestring):
        locales = [locales]

    # try to set the different locales, fallback on the default.
    if not locales:
        locales = _DEFAULT_CONFIG['LOCALE']

    for locale_ in locales:
        try:
            locale.setlocale(locale.LC_ALL, locale_)
            break  # break if it is successfull
        except locale.Error:
            pass
    else:
        log.warn("LOCALE option doesn't contain a correct value")

    if not 'TIMEZONE' in context:
        log.warn("No timezone information specified in the settings. Assuming your "\
                "timezone is UTC for feed generation. "\
                "Check http://docs.notmyidea.org/alexis/pelican/settings.html#timezone "\
                "for more information")

    # set the locale
    return context
예제 #3
0
파일: settings.py 프로젝트: n1k0/pelican
def read_settings(filename):
    """Load a Python file into a dictionary.
    """
    context = _DEFAULT_CONFIG.copy()
    if filename:
        tempdict = {}
        execfile(filename, tempdict)
        for key in tempdict:
            if key.isupper():
                context[key] = tempdict[key]

        # Make the paths relative to the settings file
        for path in ["PATH", "OUTPUT_PATH"]:
            if path in context:
                if context[path] is not None and not os.path.isabs(context[path]):
                    # FIXME:
                    context[path] = os.path.abspath(
                        os.path.normpath(os.path.join(os.path.dirname(filename), context[path]))
                    )

    # if locales is not a list, make it one
    locales = context["LOCALE"]

    if isinstance(locales, basestring):
        locales = [locales]

    # try to set the different locales, fallback on the default.
    if not locales:
        locales = _DEFAULT_CONFIG["LOCALE"]

    for locale_ in locales:
        try:
            locale.setlocale(locale.LC_ALL, locale_)
            break  # break if it is successfull
        except locale.Error:
            pass
    else:
        log.warn("LOCALE option doesn't contain a correct value")

    if not "TIMEZONE" in context:
        log.warn(
            "No timezone information specified in the settings. Assuming your "
            "timezone is UTC for feed generation. "
            "Check http://docs.notmyidea.org/alexis/pelican/settings.html#timezone "
            "for more information"
        )

    # set the locale
    return context
예제 #4
0
def read_settings(filename):
    """Load a Python file into a dictionary.
    """
    context = _DEFAULT_CONFIG.copy()
    if filename:
        tempdict = {}
        execfile(filename, tempdict)
        for key in tempdict:
            if key.isupper():
                context[key] = tempdict[key]

    # if locales is not a list, make it one
    locales = context['LOCALE']

    if isinstance(locales, basestring):
        locales = [locales]

    # try to set the different locales, fallback on the default.
    if not locales:
        locales = _DEFAULT_CONFIG['LOCALE']

    for locale_ in locales:
        try:
            locale.setlocale(locale.LC_ALL, locale_)
            break  # break if it is successfull
        except locale.Error:
            pass
    else:
        log.warn("LOCALE option doesn't contain a correct value")

    # Make the paths relative to the settings file
    for path in ['PATH', 'OUTPUT_PATH']:
        if path in context:
            if context[path] is not None and not os.path.isabs(context[path]):
                context[path] = os.path.abspath(
                    os.path.normpath(
                        os.path.join(os.path.dirname(filename),
                                     context[path])))

    # set the locale
    return context
예제 #5
0
def read_settings(filename):
    """Load a Python file into a dictionary.
    """
    context = _DEFAULT_CONFIG.copy()
    if filename:
        tempdict = {}
        execfile(filename, tempdict)
        for key in tempdict:
            if key.isupper():
                context[key] = tempdict[key]

        # Make the paths relative to the settings file
        for path in ['PATH', 'OUTPUT_PATH']:
            if path in context:
                if context[path] is not None and not os.path.isabs(context[path]):
                    # FIXME:
                    context[path] = os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(filename), context[path])))

    # if locales is not a list, make it one
    locales = context['LOCALE']

    if isinstance(locales, basestring):
        locales = [locales]

    # try to set the different locales, fallback on the default.
    if not locales:
        locales = _DEFAULT_CONFIG['LOCALE']

    for locale_ in locales:
        try:
            locale.setlocale(locale.LC_ALL, locale_)
            break # break if it is successfull
        except locale.Error:
            pass
    else:
        log.warn("LOCALE option doesn't contain a correct value")

    # set the locale
    return context