Thin wrapper around the ttfautohint command line tool.

    Can take in command line arguments directly as a string, or spelled out as
    Python keyword arguments.
163760
def ttfautohint(in_file, out_file, args=None, **kwargs):
    

    arg_list = ["ttfautohint"]
    file_args = [in_file, out_file]

    if args is not None:
        if kwargs:
            raise TypeError("Should not provide both cmd args and kwargs.")
        rv = subprocess.call(arg_list + args.split() + file_args)
        if rv != 0:
            raise TTFAError(rv)
        return

    boolean_options = (
        "debug",
        "composites",
        "dehint",
        "help",
        "ignore_restrictions",
        "detailed_info",
        "no_info",
        "adjust_subglyphs",
        "symbol",
        "ttfa_table",
        "verbose",
        "version",
        "windows_compatibility",
    )
    other_options = (
        "default_script",
        "fallback_script",
        "family_suffix",
        "hinting_limit",
        "fallback_stem_width",
        "hinting_range_min",
        "control_file",
        "hinting_range_max",
        "strong_stem_width",
        "increase_x_height",
        "x_height_snapping_exceptions",
    )

    for option in boolean_options:
        if kwargs.pop(option, False):
            arg_list.append("--" + option.replace("_", "-"))

    for option in other_options:
        arg = kwargs.pop(option, None)
        if arg is not None:
            arg_list.append("--{}={}".format(option.replace("_", "-"), arg))

    if kwargs:
        raise TypeError("Unexpected argument(s): " + ", ".join(kwargs.keys()))

    rv = subprocess.call(arg_list + file_args)
    if rv != 0:
        raise TTFAError(rv)
287462
def parse_commandline(argv):
  
  ap = ArgumentParser(
    prog='wdiffhtml',
    description=DESCRIPTION,
    epilog=EPILOG,
  )
  ap.add_argument(
    '--version', action='version', version='wdiffhtml v{}'.format(version),
    help="shows version and exits"
  )
  ap.add_argument(
    'org_file', metavar='FILENAME',
    help="original file"
  )
  ap.add_argument(
    'new_file', metavar='FILENAME',
    help="changed file"
  )
  g_html = ap.add_argument_group(
    'Wrapper',
    "Without these settings, only the `wdiff` output is returned (with INS "
    "and DEL tags). Here are some options to wrap the output in a HTML "
    "document."
  )
  g_html.add_argument(
    '-w', '--wrap-with-html', action='store_true',
    help="wrap the diff with a HTML document"
  )
  g_html.add_argument(
    '-f', '--fold-tags', action='store_true',
    help="allow INS and DEL tags to span linebraks"
  )
  g_html.add_argument(
    '-b', '--hard-breaks', action='store_true',
    help="replace line breaks with BR tags"
  )
  g_context = ap.add_argument_group(
    'Context',
    "With these options you can add additional information to the HTML "
    "output (means these only work alongside the `--wrap-with-html` option)."
  )
  g_context.add_argument(
    '-r', '--revision', metavar='STRING',
    help="add a revision tag or version number to the output"
  )
  x_stamp = g_context.add_mutually_exclusive_group()
  x_stamp.add_argument(
    '-d', '--datestamp', action='store_true',
    help="add a date to the output (UTC now)"
  )
  x_stamp.add_argument(
    '-D', '--timestamp', action='store_true',
    help="add date and time to the output (UTC now)"
  )
  g_files = ap.add_argument_group(
    'Files',
    "Instead of using the default templates, you can use your own files. "
    "These only work alongside the `--wrap-with-html` option"
  )
  g_files.add_argument(
    '-t', '--template', type=FileType('r'), metavar='FILE',
    help="load the Jinja2 template from this file"
  )
  g_files.add_argument(
    '-c', '--css', type=FileType('r'), metavar='FILE',
    help="load CSS from this file"
  )
  g_files.add_argument(
    '-j', '--js', type=FileType('r'), metavar='FILE',
    help="load Javascript from this file"
  )
  g_files.add_argument(
    '-J', '--js2', type=FileType('r'), metavar='FILE',
    help="load another Javascript from this file (like Zepto)"
  )
  # parse args
  args = ap.parse_args(argv)
  # check for wrapper
  if not args.wrap_with_html:
    # check context arguments and file arguments
    for group in (g_context, g_files):
      args_to_check = [opt.dest for opt in group._group_actions]
      if any([getattr(args, attr) for attr in args_to_check]):
        msg = "the options require that `--wrap-with-html` is used"
        ap.error(msg)
  return args
761523
def kwargs_to_string(kwargs):
    
    outstr = ''
    for arg in kwargs:
        outstr += ' -{} {}'.format(arg, kwargs[arg])
    return outstr
483775
def emit_path_arg(keywordstr, arg, fd, indent, max_line_len, line_len, eol):
    """"""

    quote = '"'

    arg = escape_str(arg)

    if not(need_new_line(max_line_len, line_len, arg)):
        fd.write(" " + quote + arg + quote)
        return False

    ## FIXME: we should split the path on '/' and '[]' into multiple lines
    ## and then print each line

    num_chars = max_line_len - line_len
    if num_chars <= 0:
        # really small max_line_len; we give up
        fd.write(" " + quote + arg + quote)
        return False

    while num_chars > 2 and arg[num_chars - 1:num_chars].isalnum():
        num_chars -= 1
    fd.write(" " + quote + arg[:num_chars] + quote)
    arg = arg[num_chars:]
    keyword_cont = ((len(keywordstr) - 1) * ' ') + '+'
    while arg != '':
        line_len = len(
            "%s%s %s%s%s%s" % (indent, keyword_cont, quote, arg, quote, eol))
        num_chars = len(arg) - (line_len - max_line_len)
        while num_chars > 2 and arg[num_chars - 1:num_chars].isalnum():
            num_chars -= 1
        fd.write('\n' + indent + keyword_cont + " " +
                 quote + arg[:num_chars] + quote)
        arg = arg[num_chars:]
943896
def argparser_factory(self):
        

        return ArgumentParser(
            prog=self.prog, description=self.__doc__, add_help=False,
        )
114233
def convert_arguments(value):
    """"""
    if isinstance(value, (list, tuple)):
        return [
            CommandLineBinding(**item) if isinstance(item, dict) else item
            for item in value
        ]
    return shlex.split(value)
1294991
def parse_args(parser: ArgumentParser) -> Any:
        """"""
        extra_usage = '''
            :folder str
                Folder to load wav files from
            
            :-tf --tags-folder str {folder}
                Specify a different folder to load file ids
                in tags file from
            
            :-tg --tags-file str -
                Text file to load tags from where each line is
                <file_id> TAB (wake-word|not-wake-word) and
                {folder}/<file_id>.wav exists
            
        '''
        add_to_parser(parser, extra_usage)
        args = parser.parse_args()
        args.tags_folder = args.tags_folder.format(folder=args.folder)
        return args
649857
def make_argparser():
    """"""

    if PY2:
        def unicode_arg(val):
            return val.decode(sys.getfilesystemencoding() or 'utf8')
    else:
        unicode_arg = str

    # Generic options
    p_main = ArgumentParser()
    generic = p_main.add_argument_group("generic arguments")
    generic.add_argument("-q", "--quiet",
                         action='store_true', dest='quiet', default=False,
                         help="silence information messages")
    generic.add_argument("-f", "--force",
                         action='store_true', dest='force', default=False,
                         help="Kill connections automatically if they prevent a command from executing. "
                              "Rename existing databases that are in the way.")
    generic.add_argument("--traceback", action='store_true', default=False,
                         help="print traceback when an error occurs")
    generic.add_argument("--host", metavar="HOST",
                         help="hostname of database server")
    generic.add_argument("-p", "--port", metavar="PORT", type=int,
                         help="port number of database server")

    sub = p_main.add_subparsers(metavar="COMMAND", dest='cmd')

    p_cp = sub.add_parser('cp', description=cmd_copy.__doc__,
                          help="Create a copy of a database within a server")
    p_mv = sub.add_parser('mv', description=cmd_move.__doc__,
                          help="Rename a database within a server")

    for p_cmd in (p_cp, p_mv):
        p_cmd.add_argument('src', metavar="SOURCE", type=unicode_arg,
                           help="source database name")
        p_cmd.add_argument('dest', metavar="DEST", type=unicode_arg,
                           help="destination database name")
        p_cmd.add_argument("--no-backup",
                           action='store_true', dest='no_backup', default=False,
                           help="drop existing DEST database if it exists")

    p_kill = sub.add_parser('kill', description=cmd_kill.__doc__,
                            help="Terminate active connections to a database")
    p_kill.add_argument('databases', metavar="DBNAME", type=unicode_arg, nargs='+',
                        help="kill connections on this database")

    p_reindex = sub.add_parser('reindex', description=cmd_reindex.__doc__,
                               help="Gracefully recreate an index")
    p_reindex.add_argument('-d', '--database', metavar="DB", type=unicode_arg,
                           help="apply reindex in this database")
    p_reindex.add_argument('indexes', metavar="IDXNAME", type=unicode_arg, nargs='+',
                           help="reindex these indexes")

    return p_main
1035151
def get_command_line(self):
        
        (Buffer, MaximumLength) = self.get_command_line_block()
        CommandLine = self.peek_string(Buffer, dwMaxSize=MaximumLength,
                                                            fUnicode=True)
        gst = win32.GuessStringType
        if gst.t_default == gst.t_ansi:
            CommandLine = CommandLine.encode('cp1252')
        return CommandLine
159567
def parse_command_line():
    """"""
    parser = argparse.ArgumentParser(
        prog='csp_pulsar_sender',
        description='Send fake pulsar data using ftp protocol.')
    parser.add_argument('config_file', type=argparse.FileType('r'),
                        help='JSON configuration file.')
    parser.add_argument('-v', '--verbose', help='Enable verbose messages.',
                        action='store_true')
    parser.add_argument('-p', '--print_settings', help='Print settings file.',
                        action='store_true')
    return parser.parse_args()
482183
def echo_arguments(*args, **kwargs):
    
    args_string = ', '.join(map(lambda x: str(x), args))
    kwargs_string = ', '.join(map(lambda k, v: "%s=%s" % (k, v), iteritems(kwargs)))
    string_lst = filter(lambda x: bool(x), [args_string, kwargs_string])
    return "ditto(%s)" % ", ".join(string_lst)
1286147
def __stringlist(self, ttype, tvalue):
        
        if ttype == "string":
            self.__curstringlist += [tvalue.decode("utf-8")]
            self.__set_expected("comma", "right_bracket")
            return True
        if ttype == "comma":
            self.__set_expected("string")
            return True
        if ttype == "right_bracket":
            self.__curcommand.check_next_arg("stringlist", self.__curstringlist)
            self.__cstate = self.__arguments
            return self.__check_command_completion()
        return False
922163
def arg_parser(*args, **kwargs):
    """"""
    msg = {
        'site': 'The site to connect to defined in your praw.ini file.',
        'update': 'Prevent the checking for prawtools package updates.'}

    kwargs['version'] = 'BBoe\'s PRAWtools {}'.format(__version__)
    parser = OptionParser(*args, **kwargs)
    parser.add_option('-v', '--verbose', action='count', default=0,
                      help='Increase the verbosity by 1 each time')
    parser.add_option('-U', '--disable-update-check', action='store_true',
                      help=msg['update'])

    group = OptionGroup(parser, 'Site/Authentication options')
    group.add_option('-S', '--site', help=msg['site'])
    parser.add_option_group(group)

    return parser
950352
def _string_from_cmd_list(cmd_list):
    """"""
    cl = []
    for arg in map(str, cmd_list):
        if ' ' in arg or '\t' in arg:
            arg = '"' + arg + '"'
        cl.append(arg)
    return ' '.join(cl)
975661
def _parse_input_parameters(self):
        
        Global.LOGGER.debug("define and parsing command line arguments")
        parser = argparse.ArgumentParser(
            description='A workflow engine for Pythonistas', formatter_class=argparse.RawTextHelpFormatter)
        parser.add_argument('FILENAME', nargs='+',help='name of the recipe file(s)')
        parser.add_argument('-i', '--INTERVAL', type=int, default=500,
                            metavar=('MS'),
                            help='perform a cycle each [MS] milliseconds. (default = 500)')

        parser.add_argument('-m', '--MESSAGEINTERVAL', type=int, 
                            metavar=('X'),
                            help='dequeue a message each [X] tenth of milliseconds. (default = auto)')
        parser.add_argument('-s', '--STATS', type=int, default=0,
                            metavar=('SEC'),
                            help='show stats each [SEC] seconds. (default = NO STATS)')
        parser.add_argument('-t', '--TRACE', action='store_true',help='enable super verbose output, only useful for tracing')                            
        parser.add_argument('-v', '--VERBOSE', action='store_true',help='enable verbose output')
        parser.add_argument('-V', '--VERSION',
                            action="version", version=__version__)

        args = parser.parse_args()
        return args
68455
def _do_create_keywords(args, kw):
    
    v = kw.get('varlist', ())
    # prevent varlist="FOO" from being interpreted as ['F', 'O', 'O']
    if is_String(v): v = (v,)
    kw['varlist'] = tuple(v)
    if args:
        # turn positional args into equivalent keywords
        cmdstrfunc = args[0]
        if cmdstrfunc is None or is_String(cmdstrfunc):
            kw['cmdstr'] = cmdstrfunc
        elif callable(cmdstrfunc):
            kw['strfunction'] = cmdstrfunc
        else:
            raise SCons.Errors.UserError(
                'Invalid command display variable type. '
                'You must either pass a string or a callback which '
                'accepts (target, source, env) as parameters.')
        if len(args) > 1:
            kw['varlist'] = tuple(SCons.Util.flatten(args[1:])) + kw['varlist']
    if kw.get('strfunction', _null) is not _null \
                      and kw.get('cmdstr', _null) is not _null:
        raise SCons.Errors.UserError(
            'Cannot have both strfunction and cmdstr args to Action()')
626361
def parse_command_line(self, argv=None):
        
        if self.config:
            parser = argparse.ArgumentParser(add_help=False)
            self.settings['config'].add_argument(parser)
            opts, _ = parser.parse_known_args(argv)
            if opts.config is not None:
                self.set('config', opts.config)

            self.params.update(self.import_from_module())

        parser = self.parser()
        opts = parser.parse_args(argv)
        for k, v in opts.__dict__.items():
            if v is None:
                continue
            self.set(k.lower(), v)