# Path: radarpost/config.py
# CONFIG_INI_PARSER_PLUGIN = 'radarpost.config.configiniparser'
# 
# def parse_bool(b):
#     if isinstance(b, bool): 
#         return b
#     if isinstance(b, int): 
#         return b != 0
#     elif isinstance(b, basestring): 
#         if b.lower() == 'true': 
#             return True
#         elif b.lower() == 'false': 
#             return False        
#     raise ValueError('Cannot parse "%s" as a boolean (True or False)' % b)
# 
# def config_section(section, config, reprefix=''):
#     if not section.endswith('.'):
#         section = section + '.'
#     section_options = {}
#     for k in config.keys():
#         if k.startswith(section): 
#             section_options[reprefix + k[len(section):]] = config[k]
#     return section_options
# 
# Path: radarpost/plugins.py
# ENTRY_POINT = 'radarpost_plugins'
# def get(slot):
# def _get(slot):
# def register(thing, slot):
# def plugin(slot):
#     def dd(thing):
# def _search():


from httplib2 import Http as UnrestrictedHttp
from tinfoilhat import Http as RestrictedHttp
from radarpost.config import CONFIG_INI_PARSER_PLUGIN, parse_bool, config_section
from radarpost import plugins
        kw['cache'] = cfg['cache']
    
    if cfg.get('allow_local') == True: 
        client = UnrestrictedHttp(**kw)
    else:
        client = RestrictedHttp(**kw)

    client.force_exception_to_status_code = True
    
    return client
    
def close_all(client):
    """
    Force-close all connections on an 
    Http object.  Set the Connection: close 
    header to force most to close automatically 
    for well behaved servers.  This cleans up
    after servers that do not behave.  
    
    See:
    http://groups.google.com/group/httplib2-dev/browse_thread/thread/55cafd03850d895?pli=1
    http://code.google.com/p/httplib2/issues/detail?id=41    
    """
    for conn in client.connections.values():
        conn.close()
    client.connections = {}

@plugins.plugin(CONFIG_INI_PARSER_PLUGIN)
def parse_http_config(cfg):
    if 'http.allow_local' in cfg: 

# Path: radarpost/config.py
# CONFIG_INI_PARSER_PLUGIN = 'radarpost.config.configiniparser'
# 
# def parse_bool(b):
#     if isinstance(b, bool): 
#         return b
#     if isinstance(b, int): 
#         return b != 0
#     elif isinstance(b, basestring): 
#         if b.lower() == 'true': 
#             return True
#         elif b.lower() == 'false': 
#             return False        
#     raise ValueError('Cannot parse "%s" as a boolean (True or False)' % b)
# 
# def config_section(section, config, reprefix=''):
#     if not section.endswith('.'):
#         section = section + '.'
#     section_options = {}
#     for k in config.keys():
#         if k.startswith(section): 
#             section_options[reprefix + k[len(section):]] = config[k]
#     return section_options
# 
# Path: radarpost/plugins.py
# ENTRY_POINT = 'radarpost_plugins'
# def get(slot):
# def _get(slot):
# def register(thing, slot):
# def plugin(slot):
#     def dd(thing):
# def _search():


# Path: radarpost/http.py
from httplib2 import Http as UnrestrictedHttp
from tinfoilhat import Http as RestrictedHttp
from radarpost.config import CONFIG_INI_PARSER_PLUGIN, parse_bool, config_section
from radarpost import plugins

        kw['cache'] = cfg['cache']
    
    if cfg.get('allow_local') == True: 
        client = UnrestrictedHttp(**kw)
    else:
        client = RestrictedHttp(**kw)

    client.force_exception_to_status_code = True
    
    return client
    
def close_all(client):
    """
    Force-close all connections on an 
    Http object.  Set the Connection: close 
    header to force most to close automatically 
    for well behaved servers.  This cleans up
    after servers that do not behave.  
    
    See:
    http://groups.google.com/group/httplib2-dev/browse_thread/thread/55cafd03850d895?pli=1
    http://code.google.com/p/httplib2/issues/detail?id=41    
    """
    for conn in client.connections.values():
        conn.close()
    client.connections = {}

@plugins.plugin(CONFIG_INI_PARSER_PLUGIN)
def parse_http_config(cfg):
    if 'http.allow_local' in cfg: 

        cfg['http.allow_local'] = parse_bool(cfg['http.allow_local'])