# Path: xdfile/utils.py
# def log(s, minverbose=0, severity='INFO'):
#     # This can be made in more Python way
#     if g_logfp.isatty(): # Colors only for atty term
#         if severity.lower() == 'warning':
#             s = bcolors.WARNING + s + bcolors.ENDC
#         if severity.lower() == 'error':
#             s = bcolors.FAIL + s + bcolors.ENDC
# 
#     if g_logfp:
#         g_logfp.write("%s: %s\n" % (severity.upper(), s))
#     g_logs.append("%s: [%s] %s" % (g_currentProgress or g_scriptname, severity.upper(), s))
# 
# def error(_s, _m=0):
#     log(_s, minverbose=_m, severity='error')
# 
# def warn(_s, _m=0):
#     log(_s, minverbose=_m, severity='warning')


import string
import puz
import crossword
import urllib.request, urllib.parse, urllib.error
import time
import xdfile
    import sys
from .utils import log, error, warn
    from utils import get_args, find_files
            if c == 0x80: circles.append(i)
    if circles: xd.set_header("Special", "circle")

    for r, row in enumerate(puzzle):
        rowstr = ""
        for c, cell in enumerate(row):
            if puzzle.block is None and cell.solution == '.':
                rowstr += xdfile.BLOCK_CHAR
            elif cell.solution == puzzle.block:
                rowstr += xdfile.BLOCK_CHAR
            elif cell.solution == ':':
                rowstr += xdfile.OPEN_CHAR
            elif cell == puzzle.empty:
                rowstr += xdfile.UNKNOWN_CHAR
            else:
                n = r * puzobj.width + c
                reb = puzobj.rebus()
                if reb.has_rebus() and n in reb.get_rebus_squares():
                    ch = str(reb.table[n] - 1)
                    rowstr += used_rebuses[ch]
                    cell.solution = rebus[used_rebuses[ch]]
                else:
                    ch = cell.solution
                    if ch not in grid_dict:
                        if ch in rebus_shorthands:
                            cellch = ch
                            rebus_shorthands.remove(ch)
                            warn("%s: unknown grid character '%s', assuming rebus of itself" % (filename, ch))
                        else:
                            cellch = rebus_shorthands.pop()

# Path: xdfile/utils.py
# def log(s, minverbose=0, severity='INFO'):
#     # This can be made in more Python way
#     if g_logfp.isatty(): # Colors only for atty term
#         if severity.lower() == 'warning':
#             s = bcolors.WARNING + s + bcolors.ENDC
#         if severity.lower() == 'error':
#             s = bcolors.FAIL + s + bcolors.ENDC
# 
#     if g_logfp:
#         g_logfp.write("%s: %s\n" % (severity.upper(), s))
#     g_logs.append("%s: [%s] %s" % (g_currentProgress or g_scriptname, severity.upper(), s))
# 
# def error(_s, _m=0):
#     log(_s, minverbose=_m, severity='error')
# 
# def warn(_s, _m=0):
#     log(_s, minverbose=_m, severity='warning')


# Path: xdfile/puz2xd.py
import string
import puz
import crossword
import urllib.request, urllib.parse, urllib.error
import time
import xdfile
    import sys
from .utils import log, error, warn
    from utils import get_args, find_files

            if c == 0x80: circles.append(i)
    if circles: xd.set_header("Special", "circle")

    for r, row in enumerate(puzzle):
        rowstr = ""
        for c, cell in enumerate(row):
            if puzzle.block is None and cell.solution == '.':
                rowstr += xdfile.BLOCK_CHAR
            elif cell.solution == puzzle.block:
                rowstr += xdfile.BLOCK_CHAR
            elif cell.solution == ':':
                rowstr += xdfile.OPEN_CHAR
            elif cell == puzzle.empty:
                rowstr += xdfile.UNKNOWN_CHAR
            else:
                n = r * puzobj.width + c
                reb = puzobj.rebus()
                if reb.has_rebus() and n in reb.get_rebus_squares():
                    ch = str(reb.table[n] - 1)
                    rowstr += used_rebuses[ch]
                    cell.solution = rebus[used_rebuses[ch]]
                else:
                    ch = cell.solution
                    if ch not in grid_dict:
                        if ch in rebus_shorthands:
                            cellch = ch
                            rebus_shorthands.remove(ch)
                            warn("%s: unknown grid character '%s', assuming rebus of itself" % (filename, ch))
                        else:
                            cellch = rebus_shorthands.pop()

                            warn("%s: unknown grid character '%s', assuming rebus (as '%s')" % (filename, ch, cellch))