# Path: falsy/loader/func.py
# def load(function_name):
#     if not function_name:
#         return None
# 
#     if function_name in func_map.keys():
#         return func_map[function_name]
# 
#     module_name, attr_path = function_name.rsplit('.', 1)
#     module = None
#     last_import_error = None
# 
#     while not module:
# 
#         try:
#             module = importlib.import_module(module_name)
#         except ImportError as import_error:
#             last_import_error = import_error
#             if '.' in module_name:
#                 module_name, attr_path1 = module_name.rsplit('.', 1)
#                 attr_path = '{0}.{1}'.format(attr_path1, attr_path)
#             else:
#                 raise
#     try:
#         function = deep_getattr(module, attr_path)
#     except AttributeError:
#         if last_import_error:
#             raise last_import_error
#         else:
#             raise
#     func_map[str(function_name)] = function
#     return function


import json
import re
import pycurl
import uuid
from falsy.loader.func import load

    debug = p.get('debugfunction')
    if debug:
        c.setopt(pycurl.DEBUGFUNCTION, load(debug))
    c.setopt(pycurl.VERBOSE, p.get('verbose', 0))

    proxy = p.get('proxy')
    proxyport = p.get('proxyport')
    proxytype = p.get('proxytype')
    proxyuserpwd = p.get('proxyuserpwd')
    if proxy and proxyport and proxytype:
        c.setopt(pycurl.PROXY, proxy)
        c.setopt(pycurl.PROXYPORT, proxyport)
        c.setopt(pycurl.PROXYTYPE, proxytype)
        if proxyuserpwd:
            c.setopt(pycurl.PROXYUSERPWD, proxyuserpwd)


def setup_curl_for_get(c, p, data_buf, headers=None, share=None):
    setup_curl_basic(c, p, data_buf, headers, share)
    httpheader = p.get('httpheader')
    if httpheader:
        # c.setopt(pycurl.HEADER, p.get('header', 1))
        c.setopt(c.HTTPHEADER, httpheader)
    return c


def setup_curl_for_post(c, p, data_buf, headers=None, share=None):
    setup_curl_basic(c, p, data_buf, headers, share)
    httpheader = p.get('httpheader', ['Accept: application/json', "Content-type: application/json"])

# Path: falsy/loader/func.py
# def load(function_name):
#     if not function_name:
#         return None
# 
#     if function_name in func_map.keys():
#         return func_map[function_name]
# 
#     module_name, attr_path = function_name.rsplit('.', 1)
#     module = None
#     last_import_error = None
# 
#     while not module:
# 
#         try:
#             module = importlib.import_module(module_name)
#         except ImportError as import_error:
#             last_import_error = import_error
#             if '.' in module_name:
#                 module_name, attr_path1 = module_name.rsplit('.', 1)
#                 attr_path = '{0}.{1}'.format(attr_path1, attr_path)
#             else:
#                 raise
#     try:
#         function = deep_getattr(module, attr_path)
#     except AttributeError:
#         if last_import_error:
#             raise last_import_error
#         else:
#             raise
#     func_map[str(function_name)] = function
#     return function


# Path: falsy/netboy/utils.py
import json
import re
import pycurl
import uuid
from falsy.loader.func import load


    debug = p.get('debugfunction')
    if debug:
        c.setopt(pycurl.DEBUGFUNCTION, load(debug))
    c.setopt(pycurl.VERBOSE, p.get('verbose', 0))

    proxy = p.get('proxy')
    proxyport = p.get('proxyport')
    proxytype = p.get('proxytype')
    proxyuserpwd = p.get('proxyuserpwd')
    if proxy and proxyport and proxytype:
        c.setopt(pycurl.PROXY, proxy)
        c.setopt(pycurl.PROXYPORT, proxyport)
        c.setopt(pycurl.PROXYTYPE, proxytype)
        if proxyuserpwd:
            c.setopt(pycurl.PROXYUSERPWD, proxyuserpwd)


def setup_curl_for_get(c, p, data_buf, headers=None, share=None):
    setup_curl_basic(c, p, data_buf, headers, share)
    httpheader = p.get('httpheader')
    if httpheader:
        # c.setopt(pycurl.HEADER, p.get('header', 1))
        c.setopt(c.HTTPHEADER, httpheader)
    return c


def setup_curl_for_post(c, p, data_buf, headers=None, share=None):
    setup_curl_basic(c, p, data_buf, headers, share)
    httpheader = p.get('httpheader', ['Accept: application/json', "Content-type: application/json"])

    if httpheader: