Top level zipline entry point.
975853
def main(extension, strict_extensions, default_extension, x):
    

    # install a logbook handler before performing any other operations
    logbook.StderrHandler().push_application()
    create_args(x, zipline.extension_args)
    load_extensions(
        default_extension,
        extension,
        strict_extensions,
        os.environ,
    )
817576
def main():
    """"""
    query = ' '.join(sys.stdin.readlines())

    sys.stdout.write(pretty_print_graphql(query))
146314
def main():
    """"""
    arguments = docopt.docopt(__doc__, version=__version__)
    colorlogs()
    # Read input file file


    wrapper = BMIWrapper(
        engine=arguments['<engine>'],
        configfile=arguments['<config>'] or ''
    )


    # add logger if required
    if not arguments['--disable-logger']:
        logging.root.setLevel(logging.DEBUG)
        wrapper.set_logger(logging.root)

    with wrapper as model:
        # if siginfo is supported by OS (BSD)
        def handler(signum, frame):
            """report progress information"""
            t_start = model.get_start_time()
            t_end = model.get_end_time()
            t_current = model.get_current_time()
            total = (t_end - t_start)
            now = (t_current - t_start)
            if total > 0:
                logging.info("progress: %s%%", 100.0 * now / total)
            else:
                logging.info("progress: unknown")

        if hasattr(signal, 'SIGINFO'):
            # attach a siginfo handler (CTRL-t) to print progress
            signal.signal(signal.SIGINFO, handler)

        if arguments['--info']:
            logging.info("%s", trace(model))
        t_end = model.get_end_time()
        t = model.get_start_time()
        while t < t_end:
            model.update(-1)
            t = model.get_current_time()
        if arguments['--info']:
            logging.info("%s", trace(model))
339357
def zipline_magic(line, cell=None):
    
    load_extensions(
        default=True,
        extensions=[],
        strict=True,
        environ=os.environ,
    )
    try:
        return run.main(
            # put our overrides at the start of the parameter list so that
            # users may pass values with higher precedence
            [
                '--algotext', cell,
                '--output', os.devnull,  # don't write the results by default
            ] + ([
                # these options are set when running in line magic mode
                # set a non None algo text to use the ipython user_ns
                '--algotext', '',
                '--local-namespace',
            ] if cell is None else []) + line.split(),
            '%s%%zipline' % ((cell or '') and '%'),
            # don't use system exit and propogate errors to the caller
            standalone_mode=False,
        )
    except SystemExit as e:
        # https://github.com/mitsuhiko/click/pull/533
        # even in standalone_mode=False `--help` really wants to kill us ;_;
        if e.code:
            raise ValueError('main returned non-zero status code: %d' % e.code)
326161
def main(mode):
    
    # see:
    # https://packaging.python.org/tutorials/distributing-packages/#uploading-your-project-to-pypi
    version = subprocess.check_output(['python', 'setup.py', '--version']).decode().strip()

    twine_repo = os.getenv('TWINE_REPOSITORY_URL') or os.getenv('TWINE_REPOSITORY')
    print('tagging and releasing %r as a %s release to %s as Twine user %s' % (
        version,
        mode.name,
        twine_repo,
        os.getenv('TWINE_USERNAME')
    ))

    print('python - preparing environment')
    subprocess.check_call(['apk', 'update'])
    subprocess.check_call(['apk', 'add', 'git'])
    # Pin twine to 1.11 due to https://github.com/pypa/twine/issues/404
    subprocess.check_call(['pip', 'install', 'twine<1.12'])
    url = subprocess.check_output(['git', 'remote', 'get-url', 'origin'])
    new_url = git_url_ssh_to_https(url.decode())
    subprocess.check_call(['git', 'remote', 'set-url', 'origin', new_url])
    branch_spec = 'origin/%s' % os.getenv('CIRCLE_BRANCH')
    subprocess.check_call(['git', 'branch', '--set-upstream-to', branch_spec])
    subprocess.check_call(['git', 'fetch', '--tags', '--force'])

    # tags
    subprocess.check_call(['git', 'tag', '-a', version, '-m', 'release %s' % version])
    subprocess.check_call(['git', 'tag', '-f', 'latest'])
    if mode == release_target_map['prod']:
        print('git - pushing %s tags' % mode.name)
        subprocess.check_call(['git', 'push', '-f', 'origin', '--tags'])

    print('git - add changes')
    subprocess.check_call(['git', 'add', 'src/mbed_cloud/_version.py'])
    subprocess.check_call(['git', 'add', 'CHANGELOG.rst'])
    subprocess.check_call(['git', 'add', 'docs/news/*'])
    message = ':checkered_flag: :newspaper: releasing version %s\n[skip ci]' % version
    subprocess.check_call(['git', 'commit', '-m', message])

    if mode == release_target_map['prod']:
        print('git - pushing %s changelog commit' % mode.name)
        subprocess.check_call(['git', 'push', 'origin'])

    print('pypi - uploading')
    subprocess.check_call(['python', '-m', 'twine', 'upload', mode.bundle])
    print('pypi - uploading successful')
80451
def cli(ctx, boring, verbose, zap_path, port, zap_url, api_key, log_path):
    """"""
    console.colorize = not boring

    if verbose:
        console.setLevel('DEBUG')
    else:
        console.setLevel('INFO')

    ctx.obj = ZAPHelper(zap_path=zap_path, port=port, url=zap_url, api_key=api_key, log_path=log_path)
1025245
def pyspread(S=None):
    """"""

    # Initialize main application
    app = MainApplication(S=S, redirect=False)

    app.MainLoop()
1221652
def main(model_folder, override=False):
    """"""
    model_description_file = os.path.join(model_folder, "info.yml")
    # Read the model description file
    with open(model_description_file, 'r') as ymlfile:
        model_description = yaml.load(ymlfile)

    project_root = utils.get_project_root()
    # Read the feature description file
    feature_folder = os.path.join(project_root,
                                  model_description['data-source'])
    with open(os.path.join(feature_folder, "info.yml"), 'r') as ymlfile:
        feature_description = yaml.load(ymlfile)
    # Get a list of all used features
    feature_list = features.get_features(feature_description['features'])
    # Get the dimension of the feature vector
    input_features = sum(map(lambda n: n.get_dimension(), feature_list))
    logging.info("Number of features: %i", input_features)

    # Analyze model
    logging.info(model_description['model'])
    if model_description['model']['type'] != 'mlp':
        return
    create_model(model_folder,
                 model_description['model']['type'],
                 model_description['model']['topology'],
                 override)
    utils.create_run_logfile(model_folder)
1265364
def main():
    """"""
    from docopt import docopt; arguments = docopt(__doc__, version=package.title() + " v" + version)
    global verbose
    verbose = arguments['--verbose']

    if verbose:
	print("target folder: " + target_folder + " (" + project_path +"/" + target_folder + ")")

    if arguments['init']:
	init_current_directory()

    if arguments['build']:
	if arguments['<file>']:
	    buildFile(arguments['<file>'])
	else:
	    buildAll()

    if arguments['watch']:
	if verbose:
	    print("Watching " + project_path)
        import time
	from watchdog.observers import Observer
	event_handler = MyWatchHandler()
	observer = Observer()
	observer.schedule(event_handler, project_path, recursive=True)
	observer.start()
	try:
	    while True:
	        time.sleep(1)
	except KeyboardInterrupt:
	    observer.stop()
	observer.join()

    if arguments['clean']:
	clean()
902442
def bootstrap():  # pragma: no cover
    """"""

    # get a handle of the currently executing zip file
    archive = current_zipfile()

    # create an environment object (a combination of env vars and json metadata)
    env = Environment.from_json(archive.read("environment.json").decode())

    # get a site-packages directory (from env var or via build id)
    site_packages = cache_path(archive, env.root, env.build_id) / "site-packages"

    # determine if first run or forcing extract
    if not site_packages.exists() or env.force_extract:
        extract_site_packages(archive, site_packages.parent, env.compile_pyc, env.compile_workers, env.force_extract)

    # get sys.path's length
    length = len(sys.path)

    # Find the first instance of an existing site-packages on sys.path
    index = _first_sitedir_index() or length

    # append site-packages using the stdlib blessed way of extending path
    # so as to handle .pth files correctly
    site.addsitedir(site_packages)

    # add our site-packages to the environment, if requested
    if env.extend_pythonpath:
        _extend_python_path(os.environ, sys.path[index:])

    # reorder to place our site-packages before any others found
    sys.path = sys.path[:index] + sys.path[length:] + sys.path[index:length]

    # first check if we should drop into interactive mode
    if not env.interpreter:

        # do entry point import and call
        if env.entry_point is not None:
            mod = import_string(env.entry_point)
            try:
                sys.exit(mod())
            except TypeError:
                # catch "<module> is not callable", which is thrown when the entry point's
                # callable shares a name with it's parent module
                # e.g. "from foo.bar import bar; bar()"
                sys.exit(getattr(mod, env.entry_point.replace(":", ".").split(".")[1])())

        elif env.script is not None:
            sys.exit(runpy.run_path(site_packages / "bin" / env.script, run_name="__main__"))

    # all other options exhausted, drop into interactive mode
    execute_interpreter()
340378
def open(self):
        
        self.zf = zipfile.ZipFile(self.write_to_path, self.mode)
1102679
def main():
    '''
    
    '''
    args = CLI.parse_args(__doc__)

    if args['--verbose']:
        requests_log = logging.getLogger("requests.packages.urllib3")
        requests_log.setLevel(logging.DEBUG)
        logging.basicConfig(level=logging.DEBUG)

    if not args['-k']:
        print("No API key given. Please create an API key on <https://octopart.com/api/dashboard>")
        return ReturnValues.NO_APIKEY

    if args['-t'] == 'octopart':
        engine = PyPartsOctopart(args['-k'], verbose=args['--verbose'])
    elif args['-t'] == 'parts.io':
        engine = PyPartsPartsIO(args['-k'], verbose=args['--verbose'])
    else:
        engine = PyPartsBase(args['-k'], verbose=args['--verbose'])

    try:
        if 'lookup' in args or 'search' in args:
            return engine.part_search(args['<part>'])
        elif 'specs' in args:
            return engine.part_specs(args['<part>'])
        elif 'datasheet' in args:
            if args['<action>'] == 'open':
                if args['--output']:
                    return engine.part_datasheet(args['<part>'], command=args['--command'], path=args['--output'])
                else:
                    return engine.part_datasheet(args['<part>'], command=args['--command'])
            elif args['<action>'] == 'save':
                return engine.part_datasheet(args['<part>'], path=args['--output'])
        elif 'show' in args:
            return engine.part_show(args['<part>'], printout=args['--print'])
    except OctopartException as err:
        print(err)
        return ReturnValues.RUNTIME_ERROR
945724
def main():
    """"""

    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument(
        'reportfile', type=argparse.FileType('r'),
        help="test report file generated by `guesslang --test TESTDIR`")
    parser.add_argument(
        '-d', '--debug', default=False, action='store_true',
        help="show debug messages")

    args = parser.parse_args()
    config_logging(args.debug)

    report = json.load(args.reportfile)
    graph_data = _build_graph(report)
    index_path = _prepare_resources(graph_data)
    webbrowser.open(str(index_path))
938596
def main(_):
  """"""
  utility.set_up_logging()
  if not FLAGS.logdir or not FLAGS.outdir:
    raise KeyError('You must specify logging and outdirs directories.')
  FLAGS.logdir = os.path.expanduser(FLAGS.logdir)
  FLAGS.outdir = os.path.expanduser(FLAGS.outdir)
  visualize(
      FLAGS.logdir, FLAGS.outdir, FLAGS.num_agents, FLAGS.num_episodes,
      FLAGS.checkpoint, FLAGS.env_processes)
1046384
def main():
    """"""
    parser = argparse.ArgumentParser(
        prog='PyNews-CLI',
        description='Your news collector inside your terminal! Tell me, what\'s\
                      cooler than that?',
        usage="""
        PyNews-CLI - News Collector from HackerNews API
        Usage: pynews [-t/--top-stories number_of_stories]
                      [-n/--news-stories number_of_stories]

        If the number of stories is not supplied, will be showed 200 from the
        500 stories.

        Examples:
        - Get Top Stories:
            $ pynews -t 10 # or
            $ pynews --top-stories 10
            This will show the 10 first top stories from the list of 500.

        - Get New Stories:
            $ pynews -n 10 # or
            $ pynews --news-stories
            This will show the 10 first new stories from the list of 500.

        Get basic options and Help, use: -h\--help

        """,
    )
    parser.add_argument(
        '-t',
        '--top-stories',
        nargs='?',
        const=200,
        type=int,
        help='Get the top N stories from HackerNews API'
    )

    parser.add_argument(
        '-n',
        '--news-stories',
        nargs='?',
        const=200,
        type=int,
        help='Get the N new stories from HackerNews API'
    )

    parser.add_argument(
        '-s',
        '--shuffle',
        nargs='?',
        const=False,
        type=bool,
        help='Get the N new stories from HackerNews API'
    )

    parser.add_argument(
        '-T',
        '--threads',
        nargs='?',
        const=DEFAULT_THREADS_NUMBER,
        type=int,
        help='Determine the number max of threads'
    )

    options = parser.parse_args()

    if options.top_stories:
        param = options.top_stories, 'top'
    else:
        param = options.news_stories, 'news'

    list_data = None

    try:
        list_data = get_stories(param[1])
    except req.ConnectionError:
        print('A connection problem occurred.')
    except req.Timeout:
        print('A timeout problem occurred.')
    except req.TooManyRedirects:
        print('The request exceeds the configured number\
            of maximum redirections.')

    if not list_data:
        return

    max_threads = (
        options.threads if options.threads or 0 > 0 else DEFAULT_THREADS_NUMBER
    )

    list_dict_stories = create_list_stories(
        list_data,
        param[0],
        options.shuffle,
        max_threads
    )

    menu = create_menu(list_dict_stories, param[1])
    menu.show()
1370589
def entry_point():
    """"""
    try:
        provider_group_factory()
        notifiers_cli(obj={})
    except NotifierException as e:
        click.secho(f"ERROR: {e.message}", bold=True, fg="red")
        exit(1)
92450
def main():
    """"""
    (cred, providers) = config_read()
    cmd_mode = True
    conn_objs = cld.get_conns(cred, providers)
    while cmd_mode:
        nodes = cld.get_data(conn_objs, providers)
        node_dict = make_node_dict(nodes, "name")
        idx_tbl = table.indx_table(node_dict, True)
        cmd_mode = ui.ui_main(idx_tbl, node_dict)
    print("\033[?25h")