# Path: pdfminer/cmapdb.py
# def convert_cmap(outdir, regname, enc2codec, paths):
#     converter = CMapConverter(enc2codec)
# 
#     for path in paths:
#         print('reading: %r...' % path)
#         with open(path) as fp:
#             converter.load(fp)
# 
#     files = []
#     for enc in converter.get_encs():
#         fname = '%s.marshal.gz' % enc
#         path = os.path.join(outdir, fname)
#         print('writing: %r...' % path)
#         with gzip.open(path, 'wb') as fp:
#             converter.dump_cmap(fp, enc)
#         files.append(path)
# 
#     fname = 'to-unicode-%s.marshal.gz' % regname
#     path = os.path.join(outdir, fname)
#     print('writing: %r...' % path)
#     with gzip.open(path, 'wb') as fp:
#         converter.dump_unicodemap(fp)
#     files.append(path)
#     return files


import sys
    import getopt
from pdfminer.cmapdb import convert_cmap
#!/usr/bin/env python

# main
def main(argv):

    def usage():
        print('usage: %s [-c enc=codec] output_dir regname [cid2code.txt ...]' % argv[0])
        return 100
    try:
        (opts, args) = getopt.getopt(argv[1:], 'c:')
    except getopt.GetoptError:
        return usage()
    enc2codec = {}
    for (k, v) in opts:
        if k == '-c':
            (enc,_,codec) = v.partition('=')
            enc2codec[enc] = codec
    if not args: return usage()
    outdir = args.pop(0)
    if not args: return usage()
    regname = args.pop(0)


# Path: pdfminer/cmapdb.py
# def convert_cmap(outdir, regname, enc2codec, paths):
#     converter = CMapConverter(enc2codec)
# 
#     for path in paths:
#         print('reading: %r...' % path)
#         with open(path) as fp:
#             converter.load(fp)
# 
#     files = []
#     for enc in converter.get_encs():
#         fname = '%s.marshal.gz' % enc
#         path = os.path.join(outdir, fname)
#         print('writing: %r...' % path)
#         with gzip.open(path, 'wb') as fp:
#             converter.dump_cmap(fp, enc)
#         files.append(path)
# 
#     fname = 'to-unicode-%s.marshal.gz' % regname
#     path = os.path.join(outdir, fname)
#     print('writing: %r...' % path)
#     with gzip.open(path, 'wb') as fp:
#         converter.dump_unicodemap(fp)
#     files.append(path)
#     return files


# Path: tools/conv_cmap.py
import sys
    import getopt
from pdfminer.cmapdb import convert_cmap

#!/usr/bin/env python

# main
def main(argv):

    def usage():
        print('usage: %s [-c enc=codec] output_dir regname [cid2code.txt ...]' % argv[0])
        return 100
    try:
        (opts, args) = getopt.getopt(argv[1:], 'c:')
    except getopt.GetoptError:
        return usage()
    enc2codec = {}
    for (k, v) in opts:
        if k == '-c':
            (enc,_,codec) = v.partition('=')
            enc2codec[enc] = codec
    if not args: return usage()
    outdir = args.pop(0)
    if not args: return usage()
    regname = args.pop(0)


    convert_cmap(outdir, regname, enc2codec, args)