import os
import re
import sys


def grepper(content):
    
    non_unicode_pattern = re.compile(r'[^L](".*")')
    unicode_pattern = re.compile(r'L".*"')

    result = set()

    for match in non_unicode_pattern.findall(content):
        print match
        result.add(match)
    
    print '----------------------'

    for match in unicode_pattern.findall(content):
        print match
        result.add(match)

    result = sorted(result)
    return result
    

def generate_dictionary(all_the_strings):
    
    # 'json_number_chars':'"0123456789.+-eE"',
    # 'json_hex_chars':'"0123456789abcdefABCDEF"',
    buf = '_strings = {\n'
    
    for s in all_the_strings:
        line = '\t\'{}\':\'{}\',\n'.format(s[1:-1].replace('\\n','').replace(' ','').replace('%', '_').replace(':','').replace('"',''), s)
        buf += line

    buf = buf[:-2] + '\n}\n'

    return buf

if __name__ == '__main__':
    
    buf = ''
    for f in sys.argv[1:]:
        with open(f) as fo:
            buf += fo.read()

    string_list = grepper(buf)
    buf = generate_dictionary(string_list)

    print buf
    
    
