Main entry point of the app
511378
def main():
    
    ROOT_LOGGER.setLevel(logging.DEBUG)

    file_handler = logging.StreamHandler(LOG_PATH.open("wt"))
    formatter = logging.Formatter(LOG_FORMAT)
    file_handler.setFormatter(formatter)
    file_handler.setLevel(logging.DEBUG)
    ROOT_LOGGER.addHandler(file_handler)

    terminal_handler = logging.StreamHandler(stdout)
    terminal_handler.setFormatter(formatter)
    terminal_handler.setLevel(logging.INFO)
    ROOT_LOGGER.addHandler(terminal_handler)

    LOGGER.debug("Parsing command-line arguments")
    parser = ArgumentParser(
        description="""
            Use datasets, and judgements in the NTCIR-11 Math-2, and NTCIR-12 MathIR XHTML5 format
            to compute density, and probability estimates.
        """)
    parser.add_argument(
        "--datasets", nargs='+', required=False,
        type=lambda s: LabelledPath(s.split('=', 1)[0], Path(s.split('=', 1)[1])), help="""
            Paths to the directories containing the datasets. Each path must be prefixed with a
            unique single-letter label followed by an equals sign (e.g. "A=/some/path").
        """)
    parser.add_argument(
        "--judgements", nargs='+', required=False,
        type=lambda s: (LabelledPath.labels[s.split(':', 1)[0]], Path(s.split(':', 1)[1])), help="""
            Paths to the files containing relevance judgements. Each path must be prefixed with a
            single-letter label corresponding to the judged dataset followed by a semicolon (e.g.
            "A:/some/path/judgement.dat").
        """)
    parser.add_argument(
        "--plots", type=Path, nargs='+', help="""
            The path to the files, where the probability estimates will plotted. When no datasets
            are specified, the estimates file will be loaded.
        """)
    parser.add_argument(
        "--positions", type=Path, default=POSITIONS_ALL_PATH, help="""
            The path to the file, where the estimated positions of all paragraph identifiers from
            all datasets will be stored. Defaults to %(default)s.
        """)
    parser.add_argument(
        "--estimates", type=Path, default=ESTIMATES_PATH, help="""
            The path to the file, where the density, and probability estimates will be stored. When
            no datasets are specified, this file will be loaded to provide the estimates for
            plotting. Defaults to %(default)s.
        """)
    parser.add_argument(
        "--num-workers", type=int, default=1, help="""
            The number of processes that will be used for processing the datasets, and for computing
            the density, and probability estimates. Defaults to %(default)d.
        """)
    args = parser.parse_args()

    LOGGER.debug("Performing sanity checks on the command-line arguments")
    if args.datasets:
        for dataset in args.datasets:
            assert dataset.path.exists() and dataset.path.is_dir(), \
                "Dataset %s does not exist" % dataset.path
        assert args.judgements, "No relevance judgements were specified for the datasets"
        for _, judgement_path in args.judgements:
            assert judgement_path.exists() and judgement_path.is_file(), \
                "Relevance judgement %s does not exist" % judgement_path
        assert not args.estimates.exists() or args.estimates.is_file(), \
            "File %s, where estimates are to be stored, is non-regular." % args.estimates
        if args.positions.exists():
            LOGGER.warning("%s exists", args.positions.name)
        if args.estimates.exists():
            LOGGER.warning("%s exists", args.estimates.name)
    if args.plots:
        assert args.datasets or args.estimates, \
            "Neither datasets, not a stored file with estimates was provided as a plot source"
        if not args.datasets:
            assert args.estimates.exists() and args.estimates.is_file(), \
                "The file %s with estimates does not exist" % args.estimates
        for plot in args.plots:
            assert plot.parents[0].exists() and plot.parents[0].is_dir(), \
                "Directory %s, where a plot is to be stored, does not exist" % \
                plot.parents[0]
            if plot.exists():
                LOGGER.warning("%s exists", plot)
    assert args.positions.parents[0].exists() and args.positions.parents[0].is_dir(), \
        "Directory %s, where the positions are to be stored, does not exist" % \
        args.positions.parents[0]
    assert args.estimates.parents[0].exists() and args.estimates.parents[0].is_dir(), \
        "Directory %s, where the estimates are to be stored, does not exist" % \
        args.estimates.parents[0]
    assert args.num_workers > 0, "The number of workers must be non-negative"

    if args.datasets:
        identifiers_judged = {}
        identifiers_relevant = {}
        for dataset_path, judgement_path in args.judgements:
            LOGGER.info(
                "Retrieving judged paragraph identifiers, and scores from %s", judgement_path.name)
            if dataset_path not in identifiers_judged:
                identifiers_judged[dataset_path] = set()
            if dataset_path not in identifiers_relevant:
                identifiers_relevant[dataset_path] = set()
            with judgement_path.open("rt") as f:
                for identifier, score in get_judged_identifiers(f):
                    identifiers_judged[dataset_path].add(identifier)
                    if score > MIN_RELEVANT_SCORE:
                        identifiers_relevant[dataset_path].add(identifier)

        identifiers_all = {}
        positions_all = {}
        positions_relevant = {}
        for dataset in args.datasets:
            LOGGER.info(
                "Retrieving all paragraph identifiers, and positions from %s", dataset.path.name)
            identifiers_all[dataset.path] = []
            positions_all[dataset.path] = []
            positions_relevant[dataset.path] = []
            for directory, identifier, position in get_all_positions(
                    dataset.path, args.num_workers):
                identifiers_all[dataset.path].append((directory, identifier))
                positions_all[dataset.path].append(position)
                if identifier in identifiers_relevant[dataset.path]:
                    positions_relevant[dataset.path].append(position)

        for dataset in args.datasets:
            LOGGER.info(
                "%d / %d / %d relevant / judged / total identifiers in dataset %s",
                len(identifiers_relevant[dataset.path]), len(identifiers_judged[dataset.path]),
                len(identifiers_all[dataset.path]), dataset.path.name)

        LOGGER.info("Pickling %s", args.positions.name)
        with gzip.open(args.positions.open("wb"), "wb") as f:
            pickle.dump({
                dataset.path: {
                    identifier: position for position, (_, identifier)
                    in zip(positions_all[dataset.path], identifiers_all[dataset.path])
                } for dataset in args.datasets}, f)

        LOGGER.info("Fitting density, and probability estimators")
        estimators = get_estimators(positions_all, positions_relevant)

        LOGGER.info("Computing density, and probability estimates")
        estimates = get_estimates(estimators, SAMPLES, args.num_workers)

        LOGGER.info("Pickling %s", args.estimates.name)
        with gzip.open(args.estimates.open("wb"), "wb") as f:
            pickle.dump(estimates, f)
    else:
        LOGGER.info("Unpickling %s", args.estimates.name)
        with gzip.open(args.estimates.open("rb"), "rb") as f:
            estimates = pickle.load(f)
    if args.plots:
        figure = plot_estimates(SAMPLES, estimates)
        for plot_path in args.plots:
            LOGGER.info("Plotting %s", plot_path.name)
            figure.savefig(str(plot_path))
587008
def main():
    
    version = get_version()
    circleci_build = six.moves.input("CircleCI Build ID: ")
    appveyor_build = six.moves.input("AppVeyor Build ID: ")
    coveralls_build = six.moves.input("Coveralls Build ID: ")
    travis_build = six.moves.input("Travis Build ID: ")
    populate_readme(
        version, circleci_build, appveyor_build, coveralls_build, travis_build
    )
    populate_index(
        version, circleci_build, appveyor_build, coveralls_build, travis_build
    )
    populate_native_libraries(version)
    populate_development(version)
1060014
function main (config) {
  var aside = (
    '<button class="sidebar-toggle">' +
      '<div class="sidebar-toggle-button">' +
        '<span></span><span></span><span></span>' +
      '</div>' +
    '</button>' +
    '<aside class="sidebar">' +
      (config.name
        ? ("<h1><a class=\"app-name-link\" data-nosearch>" + (config.name) + "</a></h1>")
        : '') +
      '<div class="sidebar-nav"><!--sidebar--></div>' +
    '</aside>');

  return (isMobile ? (aside + "<main>") : ("<main>" + aside)) +
      '<section class="content">' +
        '<article class="markdown-section" id="main"><!--main--></article>' +
      '</section>' +
    '</main>'
}
1252573
public function main()
    {
        // CakeAdmin Migration
        $this->out('Migrating CakeAdmin Tables...');
        $this->migrate('CakeAdmin');
        $this->out('<info>Migrating CakeAdmin Tables completed!</info>');
        $this->hr();

        // Notifier Migration
        $this->out('Migrating Notifier Tables...');
        $this->migrate('Notifier');
        $this->out('<info>Migrating Notifier Tables completed!</info>');
        $this->hr();

        // Settings Migration
        $this->out('Migrating Settings Tables...');
        $this->migrate('Settings');
        $this->out('<info>Migrating Settings Tables completed!</info>');
        $this->hr();

        $createAdmin = $this->in('Do you want to create your first administrator?', ['Y', 'n'], 'Y');

        if ($createAdmin === 'Y') {
            $this->out('Generating a new administrator...');
            $this->dispatchShell('admin');
        }
    }
789637
function main() {
  var wtfOptions = self.options.wtfOptions || {};

  setupCommunications();

  injectScriptFile(
      'wtf_trace_web_js_compiled.js', self.options.wtfScriptContents);
  injectScriptFunction(function(options) {
    wtf.trace.prepare(options);
  }, [
    wtfOptions
  ]);
  injectScriptFunction(startTracing, []);
}
29671
public function main()
    {
        # The theme is activated.
        # Location: Resources/Themes/Default/
        Theme::active('Default');
        
        # The current settings are being configured.
        Masterpage::headPage('Sections/head')
                  ->bodyPage('Sections/body')
                  ->browserIcon(FILES_DIR . 'favicon.ico')
                  ->backgroundImage(FILES_DIR . 'background.jpg');
    }
1202728
public function main()
	{
		$ds = DIRECTORY_SEPARATOR;

		$this->_msg( 'Generating JSB2 packages' );

		$abslen = strlen( $this->_projectPath );

		foreach( $this->_arcavias->getCustomPaths( 'client/extjs' ) as $base => $paths )
		{
			foreach( $paths as $path )
			{
				$jsbPath = $base . $ds . $path;

				$message = sprintf( 'Package: %1$s ', $jsbPath );
				$this->_msg( sprintf( 'Package: %1$s ', $jsbPath ) );

				if( !is_file( $jsbPath ) || !is_readable( $jsbPath ) )
				{
					$this->_msg( $message, 'failed' );
					$this->_msg( sprintf( 'No manifest file found in %1$s', $jsbPath ) );
					continue;
				}

				try
				{
					$jsbParser = new MW_Jsb2_Default( $jsbPath );
					$jsbParser->deploy( 'js' );
					$this->_msg( $message, 'done' );
				}
				catch ( Exception $e )
				{
					$this->_msg( $message, 'failed' );
					$this->_msg( sprintf( 'Error: %1$s', $e->getMessage() ) );
				}
			}
		}
	}
201609
function main() {
    const options = queryOptions();
    switch (options.porting) {
        case 'build':
            runBuild(options)
            .catch((reason) => {
                console.error(reason);
                process.exit(1);
            });
            break;
        case 'arrange':
            runArrange(options);
            break;
        case 'rebase':
            runRebase(options);
            break;
        case 'clean':
            runClean(options);
            break;
    }
}
213026
def main():
    """"""
    logger = setup_logger()

    logger.debug('a debug message')
    logger.info('an info message')
    logger.warning('a warning message')
    logger.error('an error message')
    logger.critical('a critical message')
131306
public function main()
    {
        $this->validate();
        $this->datetimeTaskStart = new \DateTimeImmutable();

        if ($this->describeMainStack()) {
            $this->updateStacks();
        } else {
            $this->creationStacks();
        }

        while (!$this->stackIsReady()) {
            sleep(3);
            if (empty($this->events)) {
                $this->log("Waiting for stack provisioning...");
            }
        }

        $stacks = $this->describeMainStack($e);

        if (null === $stacks) {
            throw $e;
        }

        $outputLog = '';

        if ($stacks[0]['Outputs']) {
            foreach ($stacks[0]['Outputs'] as $row) {
                $outputLog .= PHP_EOL . $row['OutputKey'] . ': ' . $row['OutputValue'];
                if ($output = $this->getOutput($row['OutputKey'])) {
                    /** @var StackOutput $output */
                    $this->project->setProperty($output->getProperty(), $row['OutputValue']);
                }
            }
        }

        $this->log($outputLog);
    }
1188129
function main() {
    this.prior = this.current;
    this.current = this.current.apply(this, arguments) || this.current;
    // Call user transition function, if defined
    if (this.transition) {
        this.transition.apply(this, arguments);
    }
}
1142749
def main():
    
    parser = getBasicOptionParser()
    initializeOptions(parser)
    options = parseBasicOptions(parser)
    checkOptions(options, parser)
    config = Config()
    config.setOptions(options)
    jobStore = Toil.resumeJobStore(config.jobStore)
    stats = getStats(jobStore)
    collatedStatsTag = processData(jobStore.config, stats)
    reportData(collatedStatsTag, options)
1349850
public function main() {
        $this->stdout->styles('success', array('text' => 'green'));

        $this->hr(1);
        $this->out(sprintf('%s Steps:', $this->name));

        $counter = 1;

        foreach ($this->steps as $method) {
            $this->steps($counter);

            try {
                if (!call_user_func(array($this, $method))) {
                    $this->err('<error>Process aborted!</error>');
                    break;
                }
            } catch (Exception $e) {
                $this->err(sprintf('<error>Unexpected error has occurred; %s</error>', $e->getMessage()));
                break;
            }

            $counter++;
        }
    }
506996
def main():
    

    logging.basicConfig(level=logging.INFO)

    example_sync_client(SyncAPIClient())
    example_async_client(AsyncAPIClient())

    io_loop = ioloop.IOLoop.current()
    io_loop.start()
1298359
def main() -> None:
    """"""

    # Make sure we have access to self
    if 'self' not in globals():
        print("Run 'set locals_in_py true' and then rerun this script")
        return

    # Make sure the user passed in an output file
    if len(sys.argv) != 2:
        print("Usage: {} <output_file>".format(os.path.basename(sys.argv[0])))
        return

    # Open the output file
    outfile_path = os.path.expanduser(sys.argv[1])
    try:
        outfile = open(outfile_path, 'w')
    except OSError as e:
        print("Error opening {} because: {}".format(outfile_path, e))
        return

    # Write the help summary
    header = '{0}\nSUMMARY\n{0}\n'.format(ASTERISKS)
    outfile.write(header)

    result = app('help -v')
    outfile.write(result.stdout)

    # Get a list of all commands and help topics and then filter out duplicates
    all_commands = set(self.get_all_commands())
    all_topics = set(self.get_help_topics())
    to_save = list(all_commands | all_topics)
    to_save.sort()

    for item in to_save:
        is_command = item in all_commands
        add_help_to_file(item, outfile, is_command)

        if is_command:
            # Add any sub-commands
            for subcmd in get_sub_commands(getattr(self.cmd_func(item), 'argparser', None)):
                full_cmd = '{} {}'.format(item, subcmd)
                add_help_to_file(full_cmd, outfile, is_command)

    outfile.close()
    print("Output written to {}".format(outfile_path))
175480
async function main() {
  const { window } = webContext();
  if (window) {
    await windowReadiness(window);
    render(window);
    bootWebWorker(window);
  } else {
    console.warn("No web window. Can't run browser-demo.");
  }
}
1108168
public function main()
    {
        $pull = $this->getFactoryInstance('update');
        try {
            $pull->setBranch($this->getBranch());
        } catch (Exception $ex) {
            $this->log("Caught: " . $ex->getMessage(), Project::MSG_DEBUG);
        }
        $pull->setClean($this->getClean());
        $pull->setQuiet($this->getQuiet());

        $cwd = getcwd();

        if ($this->repository === '') {
            $prog = $this->getProject();
            $dir = $prog->getProperty('application.startdir');
        } else {
            $dir = $this->repository;
        }

        $this->checkRepositoryIsDirAndExists($dir);
        chdir($dir);
        try {
            $this->log("Executing: " . $pull->asString(), Project::MSG_INFO);
            $output = $pull->execute();
            if ($output !== '') {
                $this->log($output);
            }
        } catch (Exception $ex) {
            $msg = $ex->getMessage();
            $p = strpos($msg, 'hg returned:');
            if ($p !== false) {
                $msg = substr($msg, $p + 13);
            }
            chdir($cwd);
            throw new BuildException($msg);
        }
        chdir($cwd);
    }