def read_config_section_to_keyval_list (config_file, section=None):
    """Takes a configuration config_file and returns a list
    of options for the given or the first section found"""

    items = []
    if not file_exists(config_file):
        print ('Config file {0} does not exist'.format(config_file))
        return items

    cp = b_legacy.b_configparser()
    Config = cp()
    try:
        Config.read(config_file)
    except cp.MissingSectionHeaderError:
        print ('Config file {0} has no sections'.format(config_file))
        return items

    if section is None:
        section = Config.sections()[0]

    items = Config.items(section)
    return items
Example #2
0
"""Pyntrest module providing I/O helper methods involved during the processing
of album requests."""

from re import sub, compile, match, search
from os import path, makedirs, listdir, walk
from time import time
from codecs import open
from markdown2 import Markdown
from bptbx import b_legacy
from bptbx.b_iotools import (get_immediate_subfiles,
get_immediate_subdirectories, file_exists, findfiles)
configparser = b_legacy.b_configparser()

def cleanup_url_path (url_path):
    """Removes redundant or unwanted symbols from the provided URL path"""

    if not url_path:
        url_path = '/'

    clean_path = sub ('[/]+', '/', url_path)
    clean_path = sub ('index.html$', '', clean_path)
    return clean_path

def convert_url_path_to_local_filesystem_path (root_filesystem_path,
                                                 url_path):
    """Creates a file system sub-folder path from the given URL path and
    appends it to the given root filesystem path"""

    if not root_filesystem_path:
        root_filesystem_path = ''
    if not url_path:
Example #3
0
"""Pyntrest module providing I/O helper methods involved during the processing
of album requests."""

from re import sub, compile, match, search
from os import path, makedirs, listdir, walk
from time import time
from codecs import open
from markdown2 import Markdown
from bptbx import b_legacy
from bptbx.b_iotools import (get_immediate_subfiles,
                             get_immediate_subdirectories, file_exists,
                             findfiles)
configparser = b_legacy.b_configparser()


def cleanup_url_path(url_path):
    """Removes redundant or unwanted symbols from the provided URL path"""

    if not url_path:
        url_path = '/'

    clean_path = sub('[/]+', '/', url_path)
    clean_path = sub('index.html$', '', clean_path)
    return clean_path


def convert_url_path_to_local_filesystem_path(root_filesystem_path, url_path):
    """Creates a file system sub-folder path from the given URL path and
    appends it to the given root filesystem path"""

    if not root_filesystem_path: