import hashlib
import re

dvids_tags_in_use = [
    'exercise',
    'training',
    'interoperability',
    'partnerships',
    'activation',
    'deactivation',
    'deployment',
    'retire',
    'change of command',
    'renovations',
]

OTHERS_TAG = 'JSC_OTHERS'


def has_tags_in_use(list_array):
    for item in list_array:
        if item.lower() in dvids_tags_in_use:
            return True
    return False


def get_str_md5(param_str):
    if isinstance(param_str, str):
        param_str = param_str.encode("utf-8")
    m = hashlib.md5()
    m.update(param_str)
    return m.hexdigest()


def trim_space(input_str):
    input_str = input_str.replace("\r\n", " ")
    result = re.sub(' {2,}', ' ', input_str)
    return result


def transform_full_width_number(input_str):
    d = {
        '０': '0',
        '１': '1',
        '２': '2',
        '３': '3',
        '４': '4',
        '５': '5',
        '６': '6',
        '７': '7',
        '８': '8',
        '９': '9'
    }
    for _ in d:
        input_str = input_str.replace(_, d[_])
    return input_str
