Generate a badge based on command line arguments.
976248
def main():
    """"""
    # Parse command line arguments
    args = parse_args()

    label = args.label
    threshold_text = args.args
    suffix = args.suffix

    # Check whether thresholds were sent as one word, and is in the
    # list of templates.  If so, swap in the template.
    if len(args.args) == 1 and args.args[0] in BADGE_TEMPLATES:
        template_name = args.args[0]
        template_dict = BADGE_TEMPLATES[template_name]
        threshold_text = template_dict['threshold'].split(' ')
        if not args.label:
            label = template_dict['label']
        if not args.suffix and 'suffix' in template_dict:
            suffix = template_dict['suffix']

    if not label:
        raise ValueError('Label has not been set.  Please use --label argument.')

    # Create threshold list from args
    threshold_list = [x.split('=') for x in threshold_text]
    threshold_dict = {x[0]: x[1] for x in threshold_list}

    # Create badge object
    badge = Badge(label, args.value, value_prefix=args.prefix, value_suffix=suffix,
                  default_color=args.color, num_padding_chars=args.padding, font_name=args.font,
                  font_size=args.font_size, template=args.template,
                  use_max_when_value_exceeds=args.use_max, thresholds=threshold_dict,
                  value_format=args.value_format, text_color=args.text_color)

    if args.file:
        # Write badge SVG to file
        badge.write_badge(args.file, overwrite=args.overwrite)
    else:
        print(badge.badge_svg_text)
1258678
def generate_badge_png(title, value, color='#007ec6'):
    """"""
    badge = generate_badge_svg(title, value, color)
    return cairosvg.svg2png(badge)
396637
def parse_cmd_arguments():
    """"""
    parser = argparse.ArgumentParser()
    parser.add_argument('file', type=str,
                        help='Filename to be staticfied')
    parser.add_argument('--static-endpoint',
                        help='Static endpoint which is "static" by default')
    parser.add_argument('--add-tags', type=str,
                        help='Additional tags to staticfy')
    parser.add_argument('--exc-tags', type=str, help='tags to exclude')
    parser.add_argument('--framework', type=str,
                        help='Web Framework: Defaults to Flask')
    parser.add_argument('--namespace', type=str,
                        help='String to prefix url with')
    parser.add_argument('-o', type=str, help='Specify output file')
    parser.add_argument('--output', type=str, help='Specify output file')
    args = parser.parse_args()

    return args
533578
def do_args(self, modargs, send, nick, target, source, name, msgtype):
        """"""
        realargs = {}
        args = {
            'nick': nick,
            'handler': self,
            'db': None,
            'config': self.config,
            'source': source,
            'name': name,
            'type': msgtype,
            'botnick': self.connection.real_nickname,
            'target': target if target[0] == "#" else "private",
            'do_kick': lambda target, nick, msg: self.do_kick(send, target, nick, msg),
            'is_admin': lambda nick: self.is_admin(send, nick),
            'abuse': lambda nick, limit, cmd: self.abusecheck(send, nick, target, limit, cmd)
        }
        for arg in modargs:
            if arg in args:
                realargs[arg] = args[arg]
            else:
                raise Exception("Invalid Argument: %s" % arg)
        return realargs
796312
def generate_token(self):
        """"""

        response = self._make_request()
        self.auth = response
        self.token = response['token']
1194816
def parse_arguments():
    """"""
    parser = create_parser()
    args = parser.parse_args()
    if not args.role_requirements_old_commit:
        args.role_requirements_old_commit = args.role_requirements
    if not args.rpc_product_old_commit:
        args.rpc_product_old_commit = args.rpc_product
    return args
976279
def _generate_symbol(path, width, height, command='C'):
    """"""
    if len(path) == 0:
        return

    # Initial point.
    yield 'M'
    yield path[0].anchor[1] * width
    yield path[0].anchor[0] * height
    yield command

    # Closed path or open path
    points = (zip(path, path[1:] + path[0:1]) if path.is_closed()
              else zip(path, path[1:]))

    # Rest of the points.
    for p1, p2 in points:
        yield p1.leaving[1] * width
        yield p1.leaving[0] * height
        yield p2.preceding[1] * width
        yield p2.preceding[0] * height
        yield p2.anchor[1] * width
        yield p2.anchor[0] * height

    if path.is_closed():
        yield 'Z'
237583
def generate_from_args(self, *args):
        
        return self.generate(**dict(zip(self.variable_args, args)))
244831
def _get_args(self, executable, *args):
        """"""
        args = list(args)
        args.insert(0, executable)
        if self.username:
            args.append("--username={}".format(self.username))
        if self.host:
            args.append("--host={}".format(self.host))
        if self.port:
            args.append("--port={}".format(self.port))

        args.append(self.dbname)
        #args.extend(other_args)
        return args
143019
def main(argv=None):
    """"""
    parser = argparse.ArgumentParser(description=DESCRIPTION)
    parser.add_argument(
        'pipeline',
        help='Python dotted path to rules pipeline to document'
    )
    parser.add_argument('output', help='output file')

    if argv is None:
        args = parser.parse_args()
    else:
        args = parser.parse_args(argv)

    print('Generating documentation for %s in %s...' % (args.pipeline, args.output))

    rules = import_rules(args.pipeline)

    with open(args.output, 'w') as fp:
        fp.write('.. THIS IS AUTOGEMERATED USING:\n')
        fp.write('   \n')
        fp.write('   %s\n' % (' '.join(sys.argv)))
        fp.write('   \n')
        fp.write('Signature generation rules pipeline\n')
        fp.write('===================================\n')
        fp.write('\n')
        fp.write('\n')
        fp.write(
            'This is the signature generation pipeline defined at ``%s``:\n' %
            args.pipeline
        )
        fp.write('\n')

        for i, rule in enumerate(rules):
            li = '%s. ' % (i + 1)
            fp.write('%s%s\n' % (
                li,
                indent(get_doc(rule), ' ' * len(li))
            ))
            fp.write('\n')
1015823
def ssh_args(conn):
    """"""
    I, = conn.identities
    identity = I.identity_dict
    pubkey_tempfile, = conn.public_keys_as_files()

    args = []
    if 'port' in identity:
        args += ['-p', identity['port']]
    if 'user' in identity:
        args += ['-l', identity['user']]

    args += ['-o', 'IdentityFile={}'.format(pubkey_tempfile.name)]
    args += ['-o', 'IdentitiesOnly=true']
    return args + [identity['host']]
729953
def badge_collection(pipeline_path):
    ''''''
    all_pipeline_ids = sorted(status.all_pipeline_ids())

    if not pipeline_path.startswith('./'):
        pipeline_path = './' + pipeline_path

    # Filter pipeline ids to only include those that start with pipeline_path.
    path_pipeline_ids = \
        [p for p in all_pipeline_ids if p.startswith(pipeline_path)]

    statuses = []
    for pipeline_id in path_pipeline_ids:
        pipeline_status = status.get(pipeline_id)
        if pipeline_status is None:
            abort(404)
        status_text = pipeline_status.state().lower()
        statuses.append(status_text)

    status_color = 'lightgray'
    status_counter = Counter(statuses)
    if status_counter:
        if len(status_counter) == 1 and status_counter['succeeded'] > 0:
            status_color = 'brightgreen'
        elif status_counter['failed'] > 0:
            status_color = 'red'
        elif status_counter['failed'] == 0:
            status_color = 'yellow'
        status_text = \
            ', '.join(['{} {}'.format(v, k)
                       for k, v in status_counter.items()])
    else:
        status_text = "not found"

    return _make_badge_response('pipelines', status_text, status_color)
608238
def main(argd):
    
    startdir = argd['DIR'] or '/'
    if not os.path.isdir(startdir):
        raise InvalidArg('not a valid start directory: {}'.format(startdir))

    if argd['--progress']:
        return walk_dir_progress(startdir)
    return walk_dir_animated(startdir)
1258388
def GeneratePipPackage(args):

    """"""

    discovery_doc = _GetDiscoveryDocFromFlags(args)
    package = discovery_doc['name']
    original_outdir = os.path.expanduser(args.outdir)
    args.outdir = os.path.join(
        args.outdir, 'apitools/clients/%s' % package)
    args.root_package = 'apitools.clients.%s' % package
    codegen = _GetCodegenFromFlags(args)
    if codegen is None:
        logging.error('Failed to create codegen, exiting.')
        return 1
    _WriteGeneratedFiles(args, codegen)
    _WriteInit(codegen)
    with util.Chdir(original_outdir):
        _WriteSetupPy(codegen)
        with util.Chdir('apitools'):
            _WriteIntermediateInit(codegen)
            with util.Chdir('clients'):
                _WriteIntermediateInit(codegen)
789933
def make_command(command: Callable) -> Callable:
    """"""
    @wraps(command)
    def actualcommand(self, *args, **kwds):  # pylint: disable=missing-docstring
        data = command(self, *args, **kwds)
        name = command.__name__[3:]
        signal = '{uuid}{sep}{event}'.format(
            uuid=self._uuid,  # pylint: disable=protected-access
            sep=SEPARATOR,
            event=name
        )
        if flask.has_request_context():
            emit(signal, {'data': pack(data)})
        else:
            sio = flask.current_app.extensions['socketio']
            sio.emit(signal, {'data': pack(data)})
        eventlet.sleep()

    return actualcommand
858629
def process_args_from_command_line(self):
        """"""
        # Yes, this is ugly, but we don't want to interfere with setup.py's own
        # option handling
        opts_to_remove = []
        for idx, option in enumerate(sys.argv):
            if not option.startswith("--"):
                continue
            if option == "--static":
                opts_to_remove.append(idx)
                self.static_extension = True
            elif option == "--no-download":
                opts_to_remove.append(idx)
                self.download_igraph_if_needed = False
            elif option == "--no-pkg-config":
                opts_to_remove.append(idx)
                self.use_pkgconfig = False
            elif option == "--no-progress-bar":
                opts_to_remove.append(idx)
                self.show_progress_bar = False
            elif option == "--no-wait":
                opts_to_remove.append(idx)
                self.wait = False                
            elif option.startswith("--c-core-version"):
                opts_to_remove.append(idx)
                if option == "--c-core-version":
                    value = sys.argv[idx+1]
                    opts_to_remove.append(idx+1)
                else:
                    value = option.split("=", 1)[1]
                self.c_core_versions = [value]
            elif option.startswith("--c-core-url"):
                opts_to_remove.append(idx)
                if option == "--c-core-url":
                    value = sys.argv[idx+1]
                    opts_to_remove.append(idx+1)
                else:
                    value = option.split("=", 1)[1]
                self.c_core_url = value

        for idx in reversed(opts_to_remove):
            sys.argv[idx:(idx+1)] = []
954178
def main(args=None, vc=None, cwd=None, apply_config=False):
    """"""
    import signal

    try:  # pragma: no cover
        # Exit on broken pipe.
        signal.signal(signal.SIGPIPE, signal.SIG_DFL)
    except AttributeError:  # pragma: no cover
        # SIGPIPE is not available on Windows.
        pass

    try:
        if args is None:
            args = []

        try:
            # Note: argparse on py 2.6 you can't pass a set
            # TODO neater solution for this!
            args_set = set(args)
        except TypeError:
            args_set = args  # args is a Namespace
        if '--version' in args_set or getattr(args_set, 'version', 0):
            print(version)
            return 0
        if '--list-fixes' in args_set or getattr(args_set, 'list_fixes', 0):
            from autopep8 import supported_fixes
            for code, description in sorted(supported_fixes()):
                print('{code} - {description}'.format(
                    code=code, description=description))
            return 0

        try:
            try:
                args = parse_args(args, apply_config=apply_config)
            except TypeError:
                pass  # args is already a Namespace (testing)
            if args.from_diff:  # pragma: no cover
                r = Radius.from_diff(args.from_diff.read(),
                                     options=args, cwd=cwd)
            else:
                r = Radius(rev=args.rev, options=args, vc=vc, cwd=cwd)
        except NotImplementedError as e:  # pragma: no cover
            print(e)
            return 1
        except CalledProcessError as c:  # pragma: no cover
            # cut off usage and exit
            output = c.output.splitlines()[0]
            print(output)
            return c.returncode

        any_changes = r.fix()
        if any_changes and args.error_status:
            return 1
        return 0

    except KeyboardInterrupt:  # pragma: no cover
        return 1