Load Python Object from Pickle file.

    :param abspath: File path. Use absolute path as much as you can. File
        extension has to be ``.pickle`` or ``.gz``. (for compressed Pickle)
    :type abspath: string

    :param compress: (default False) Load from a gzip compressed Pickle file.
        Check :func:`dump_pk()<dump_pk>` function for more information.
    :type compress: boolean

    :param enable_verbose: (default True) Trigger for message.
    :type enable_verbose: boolean

    Usage::

        >>> from weatherlab.lib.dataIO.pk import load_pk
        >>> load_pk("test.pickle") # if you have a Pickle file
        Loading from test.pickle...
            Complete! Elapse 0.000272 sec.
        {'a': 1, 'b': 2}

    **中文文档**

    从Pickle文件中读取数据

    参数列表

    :param abspath: 文件路径, 扩展名需为 ``.pickle`` 或 ``.gz``
    :type abspath: ``字符串``

    :param compress: (默认 False) 是否从一个gzip压缩过的Pickle文件中读取数据。 请
        参考 :func:`dump_pk()<dump_pk>` 获得更多信息.
    :type compress: ``布尔值``

    :param enable_verbose: (默认 True) 是否打开信息提示开关, 批处理时建议关闭.
    :type enable_verbose: ``布尔值``

def load_pk(abspath, compress=False, enable_verbose=True):
    """Load Python Object from Pickle file.

    :param abspath: File path. Use absolute path as much as you can. File
        extension has to be ``.pickle`` or ``.gz``. (for compressed Pickle)
    :type abspath: string

    :param compress: (default False) Load from a gzip compressed Pickle file.
        Check :func:`dump_pk()<dump_pk>` function for more information.
    :type compress: boolean

    :param enable_verbose: (default True) Trigger for message.
    :type enable_verbose: boolean

    Usage::

        >>> from weatherlab.lib.dataIO.pk import load_pk
        >>> load_pk("test.pickle") # if you have a Pickle file
        Loading from test.pickle...
            Complete! Elapse 0.000272 sec.
        {'a': 1, 'b': 2}

    **中文文档**

    从Pickle文件中读取数据

    参数列表

    :param abspath: 文件路径, 扩展名需为 ``.pickle`` 或 ``.gz``
    :type abspath: ``字符串``

    :param compress: (默认 False) 是否从一个gzip压缩过的Pickle文件中读取数据。 请
        参考 :func:`dump_pk()<dump_pk>` 获得更多信息.
    :type compress: ``布尔值``

    :param enable_verbose: (默认 True) 是否打开信息提示开关, 批处理时建议关闭.
    :type enable_verbose: ``布尔值``
    """
    abspath = str(abspath)  # try stringlize

    msg = Messenger(enable_verbose=enable_verbose)

    if compress:  # check extension name
        if os.path.splitext(abspath)[1] != ".gz":
            raise Exception("compressed pickle has to use extension '.gz'!")
    else:
        if os.path.splitext(abspath)[1] != ".pickle":
            raise Exception("file extension are not '.pickle'!")

    msg.show("\nLoading from %s..." % abspath)
    st = time.clock()

    if compress:
        with gzip.open(abspath, "rb") as f:
            obj = pickle.loads(f.read())
    else:
        with open(abspath, "rb") as f:
            obj = pickle.load(f)

    if enable_verbose:
        msg.show("    Complete! Elapse %.6f sec" % (time.clock() - st))

    return obj