# Path: tlfp/tools/common.py
# @contextlib.contextmanager
# def log_print(file=None, only_log=False):
#     """capture all outputs to a log file while still printing it"""
#     class Logger:
#         def __init__(self, file):
#             self.terminal = sys.stdout
#             self.log = file
#             self.only_log = only_log
# 
#         def write(self, message):
#             if not self.only_log:
#                 self.terminal.write(message)
#             self.log.write(message)
# 
#         def __getattr__(self, attr):
#             return getattr(self.terminal, attr)
# 
#     if file is None:
#         file = io.StringIO()
# 
#     logger = Logger(file)
# 
#     _stdout = sys.stdout
#     _stderr = sys.stderr
#     sys.stdout = logger
#     sys.stderr = logger
#     try:
#         yield logger.log
#     finally:
#         sys.stdout = _stdout
#         sys.stderr = _stderr
# 
# Path: tlfp/tools/complete_articles.py
# def complete(current, previous, step, previous_step_metas, table_concordance=None, anteprevious=None, debug=False):
#     def log(text):
#     def exit():
#     def write_json(data):
#     def get_mark_from_last(text, s, l="", sep="", enable_copyall=False, copyall=False):
#     DEBUG = debug or '--debug' in sys.argv
#     ALL_ARTICLES = []
#     FILTERED_ALL_ARTICLES = [article for article in ALL_ARTICLES if article.get('type') != 'dots']
#     ALL_ARTICLES = FILTERED_ALL_ARTICLES


import sys, os, json
from tlfp.tools.common import log_print
from tlfp.tools import complete_articles
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))



TESTS_DIR = os.path.dirname(os.path.abspath(__file__))

with log_print() as log:
    case = json.load(open(os.path.join(TESTS_DIR, 'ressources/complete_me.json')))

# Path: tlfp/tools/common.py
# @contextlib.contextmanager
# def log_print(file=None, only_log=False):
#     """capture all outputs to a log file while still printing it"""
#     class Logger:
#         def __init__(self, file):
#             self.terminal = sys.stdout
#             self.log = file
#             self.only_log = only_log
# 
#         def write(self, message):
#             if not self.only_log:
#                 self.terminal.write(message)
#             self.log.write(message)
# 
#         def __getattr__(self, attr):
#             return getattr(self.terminal, attr)
# 
#     if file is None:
#         file = io.StringIO()
# 
#     logger = Logger(file)
# 
#     _stdout = sys.stdout
#     _stderr = sys.stderr
#     sys.stdout = logger
#     sys.stderr = logger
#     try:
#         yield logger.log
#     finally:
#         sys.stdout = _stdout
#         sys.stderr = _stderr
# 
# Path: tlfp/tools/complete_articles.py
# def complete(current, previous, step, previous_step_metas, table_concordance=None, anteprevious=None, debug=False):
#     def log(text):
#     def exit():
#     def write_json(data):
#     def get_mark_from_last(text, s, l="", sep="", enable_copyall=False, copyall=False):
#     DEBUG = debug or '--debug' in sys.argv
#     ALL_ARTICLES = []
#     FILTERED_ALL_ARTICLES = [article for article in ALL_ARTICLES if article.get('type') != 'dots']
#     ALL_ARTICLES = FILTERED_ALL_ARTICLES


# Path: tests/test_complete_articles.py
import sys, os, json
from tlfp.tools.common import log_print
from tlfp.tools import complete_articles

sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))



TESTS_DIR = os.path.dirname(os.path.abspath(__file__))

with log_print() as log:
    case = json.load(open(os.path.join(TESTS_DIR, 'ressources/complete_me.json')))

    result = complete_articles.complete(**case)