#!/usr/bin/env python
"""
Show terms use in problem description files in the given directory.
"""
from __future__ import absolute_import
import sys
import six
sys.path.append('.')
import os
from argparse import ArgumentParser

from sfepy.base.base import output, dict_from_keys_init, ordered_iteritems
from sfepy.base.conf import ProblemConf, get_standard_keywords
from sfepy.base.ioutils import locate_files
from sfepy.discrete.equations import parse_definition
from sfepy.terms import term_table

helps = {
    'counts' : 'show terms use counts only',
    'unused' : 'show unused terms only',
}

def main():
    parser = ArgumentParser(description=__doc__)
    parser.add_argument('--version', action='version', version='%(prog)s')
    parser.add_argument('-c', '--counts',
                        action='store_true', dest='counts',
                        default=False, help=helps['counts'])
    parser.add_argument('-u', '--unused',
                        action='store_true', dest='unused',
                        default=False, help=helps['unused'])
    parser.add_argument('directory')
    options = parser.parse_args()

    pdf_dir = os.path.realpath(options.directory)

    required, other = get_standard_keywords()

    terms_use = dict_from_keys_init(
term_table.keys()