def with_bloomberg(func):
@wraps(func)<EOL>def wrapper(*args, **kwargs):<EOL><INDENT>scope = utils.func_scope(func=func)<EOL>param = inspect.signature(func).parameters<EOL>port = kwargs.pop('<STR_LIT:port>', _PORT_)<EOL>timeout = kwargs.pop('<STR_LIT>', _TIMEOUT_)<EOL>restart = kwargs.pop('<STR_LIT>', False)<EOL>all_kw = {<EOL>k: args[n] if n < len(args) else v.default<EOL>for n, (k, v) in enumerate(param.items()) if k != '<STR_LIT>'<EOL>}<EOL>all_kw.update(kwargs)<EOL>log_level = kwargs.get('<STR_LIT>', logs.LOG_LEVEL)<EOL>for to_list in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>conv = all_kw.get(to_list, None)<EOL>if hasattr(conv, '<STR_LIT>'):<EOL><INDENT>all_kw[to_list] = getattr(conv, '<STR_LIT>')()<EOL><DEDENT>if isinstance(conv, str):<EOL><INDENT>all_kw[to_list] = [conv]<EOL><DEDENT><DEDENT>cached_data = []<EOL>if scope in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>to_qry = cached.bdp_bds_cache(func=func.__name__, **all_kw)<EOL>cached_data += to_qry.cached_data<EOL>if not (to_qry.tickers and to_qry.flds):<EOL><INDENT>if not cached_data: return pd.DataFrame()<EOL>res = pd.concat(cached_data, sort=False).reset_index(drop=True)<EOL>if not all_kw.get('<STR_LIT>', False):<EOL><INDENT>res = assist.format_output(<EOL>data=res, source=func.__name__,<EOL>col_maps=all_kw.get('<STR_LIT>', dict())<EOL>)<EOL><DEDENT>return res<EOL><DEDENT>all_kw['<STR_LIT>'] = to_qry.tickers<EOL>all_kw['<STR_LIT>'] = to_qry.flds<EOL><DEDENT>if scope in ['<STR_LIT>']:<EOL><INDENT>data_file = storage.hist_file(<EOL>ticker=all_kw['<STR_LIT>'], dt=all_kw['<STR_LIT>'], typ=all_kw['<STR_LIT>'],<EOL>)<EOL>if files.exists(data_file):<EOL><INDENT>logger = logs.get_logger(func, level=log_level)<EOL>if all_kw.get('<STR_LIT>', False): return<EOL>logger.debug(f'<STR_LIT>')<EOL>return assist.format_intraday(data=pd.read_parquet(data_file), **all_kw)<EOL><DEDENT><DEDENT>_, new = create_connection(port=port, timeout=timeout, restart=restart)<EOL>res = func(**{<EOL>k: v for k, v in all_kw.items() if k not in ['<STR_LIT>', '<STR_LIT>']<EOL>})<EOL>if new: delete_connection()<EOL>if scope.startswith('<STR_LIT>') and isinstance(res, list):<EOL><INDENT>final = cached_data + res<EOL>if not final: return pd.DataFrame()<EOL>res = pd.DataFrame(pd.concat(final, sort=False))<EOL><DEDENT>if (scope in ['<STR_LIT>', '<STR_LIT>'])and (not all_kw.get('<STR_LIT>', False)):<EOL><INDENT>res = assist.format_output(<EOL>data=res.reset_index(drop=True), source=func.__name__,<EOL>col_maps=all_kw.get('<STR_LIT>', dict()),<EOL>)<EOL><DEDENT>return res<EOL><DEDENT>return wrapper<EOL>
Wrapper function for Bloomberg connection

Args:
    func: function to wrap