#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# from datetime import datetime
#
# from grutils import utils
# from grutils import error
# from grutils.utils import date_of
# from grutils.excel import close_wb
# from grutils.form_utils import read_sht
# from grutils.utils import smart_repair_title


# print(utils.int_value_of("101.12", err, 0))
#
# print(date_of(datetime.date(datetime.now())))
# from grutils.error import Error
# from grutils.formatter_and_parser import parse_value
# from grutils.utils import get_value_or_exception
#
# e = Exception('aaa')
# _err = Error()
# v = parse_value('123.5', "日期")
# v = get_value_or_exception(_err, v, 'exception: {}')
# if _err.has_error():
#     print(_err.msg())
# else:
#     print(v)


# from grutils.progress import shared_progress
# from grutils.form_utils import read_sht
#
# shared_progress.reset()
#
# shared_progress.register_step("step 1", 6)
# shared_progress.register_step("step 2", 4)
# shared_progress.register_step("step 2.1", 0.6, ["step 2"])
# shared_progress.register_step("step 2.2", 0.4, ["step 2"])
# shared_progress.register_step("step 2.2.1", 1, ["step 2", "step 2.2"])
# shared_progress.register_step("step 2.2.2", 1, ["step 2", "step 2.2"])
# shared_progress.register_step("step 2.2.3", 1, ["step 2", "step 2.2"])
# shared_progress.register_step("step 2.2.4", 1, ["step 2", "step 2.2"])
# shared_progress.register_step("step 2.3", 1, ["step 2"])
# shared_progress.register_step("step 3", 10)
#
# shared_progress.re_assign_steps()
#
# shared_progress.finish_step(["step 3"])
# shared_progress.dump_steps()
#
# shared_progress.reset()
# shared_progress.finish_step(["step 2", "step 2.2", "step 2.2.1"])
# shared_progress.dump_steps()


# print('\n\n  ============== ')
# shared_progress.finish_step(["step 1"])
#
# print('\n\n  ============== ')
# shared_progress.finish_step(["step 2", "step 2.1"])
#
# print('\n\n  ============== ')
# shared_progress.finish_step(["step 2", "step 2.2", "step 2.2.1"])
# shared_progress.finish_step(["step 2", "step 2.2", "step 2.2.2"])
# shared_progress.finish_step(["step 2", "step 2.2", "step 2.2.3"])
# shared_progress.finish_step(["step 2", "step 2.2"])
#
# print('\n\n  ============== ')
# shared_progress.finish_step(["step 3"])
#
# print('\n\n  ============== ')
# shared_progress.finish()
# shared_progress.dump_steps()
#
# print('\n\n  ============== ')
# shared_progress.reset()
# shared_progress.dump_steps()
# import os.path
# import pprint
# import xlwings as xw
#
# from grutils.error import Error, build_warning_v2
# from grutils.excel import quit_app
# from grutils.utils import Configuration
# from grutils.warnings_writer import create_warnings_file, write_warnings

# c = Configuration(os.path.dirname(__file__), "test")
# pprint.pprint(c.props)
#
# c.replace_macro_in_value("${APP_ROOT_FOLDER}", "???")
# pprint.pprint(c.props)

# folder_fp = os.path.dirname(__file__)
# tpl_fp = os.path.join(folder_fp, "warnings_template.xlsx")
# fp = create_warnings_file(os.path.abspath(tpl_fp),
#                           os.path.abspath(folder_fp),
#                           "test")
# a = xw.App(visible=False, add_book=False)
# try:
#     e = Error()
#     w = build_warning_v2("file", "sheet1", 10, "has warnings")
#     e.append_warning(w)
#     write_warnings(e, fp, a)
#
#     if e.has_error():
#         print(e.msg())
#
# finally:
#     quit_app(a)
