main thread of functionality that does all the inlining
961313
function main() {
  var inliner = this;
  var url = this.source;

  return fs.exists(this.filename || url)
  .then(function exists(isFile) {
    if (!isFile) {
      throw new Error('Not a file - use URL parser');
    }

    debug('inlining file');

    inliner.isFile = true;
    inliner.url = url; // this is a hack for the `resolve` function later on
    return inliner.get(this.filename || url, { encoding: 'binary' });
  })
  .catch(function isUrl() {
    // make the best guess as to whether we're working with a url
    if (inliner.url || url.indexOf('<') === -1) {
      url = inliner.url || inliner.source;
      // check for protocol on URL
      if (url.indexOf('http') !== 0) {
        url = 'http://' + url;
      }

      inliner.url = url;

      debug('inlining url');
      return inliner.get(url, { encoding: 'binary' });
    }

    // otherwise we're dealing with an inline string
    debug('inlining by string: ', inliner.source);
    inliner.isFile = true;
    inliner.url = '.';
    var res = {
      body: new Buffer(inliner.source),
      headers: {
        'content-type': 'text/html',
      },
    };
    return res;
  })
  .then(inliner.jobs.add('html'))
  .then(function processHTML(res) {
    inliner.jobs.done.html();
    debug('processing HTML');

    debug(inliner.options);

    var body;
    var cheerioLoadOptions = {};
    var enc = inliner.options.encoding;

    // try to determine the encoding from the headers and the body
    if (!enc) {
      enc = charset(res.headers, res.body);
      enc = enc || jschardet.detect(res.body).encoding.toLowerCase();
    }

    // normalise to avoid any mistakes
    if (enc === 'utf-8' || enc === 'utf8') {
      enc = 'utf-8';
    }

    cheerioLoadOptions.decodeEntities = false;
    if (enc !== 'utf-8') {
      debug('decoding from: %s', enc);
      body = iconv.encode(iconv.decode(res.body, enc), 'utf-8');
    } else {
      body = res.body;
    }

    body = body.toString();

    // if we spot some SVG elements in the source,
    // then we'll parse as XML to correctly get the SVG
    if (body.indexOf('<?xml') !== -1 ||
        body.indexOf('<?XML') !== -1) {
      cheerioLoadOptions.xmlMode = true;
    }

    if (body.indexOf('<svg') !== -1) {
      cheerioLoadOptions.lowerCaseAttributeNames = false;
    }

    var todo = inliner.findAssets(body, cheerioLoadOptions);
    var $ = todo.$;
    delete todo.$;

    if (enc !== 'utf-8') {
      // when transcoding remove any meta tags setting the charset
      $('meta').each(function charMeta() {
        var attrs = $(this).attr();
        var content = attrs.content || '';
        if (attrs.charset || content.toLowerCase().indexOf('charset=') !== -1) {
          $(this).remove();
        }
      });
    }

    var promises = [];

    forEach(todo, function forEach(todo, key) {
      if (key === 'images' && !inliner.options.images) {
        // skip images if the user doesn't want them
        delete todo.images;
        debug('skipping images');
        return;
      }

      if (key === 'videos' && !inliner.options.videos) {
        // skip videos if the user doesn't want them
        delete todo.videos;
        debug('skipping videos');
        return;
      }

      if (!todo.length) {
        return;
      }

      inliner.jobs.add(key, todo.length);

      var tasks = taskRunner[key](inliner, todo.get(), $);
      promises = promises.concat(tasks);
    });

    return Promise.all(promises).then(function then() {
      var html = '';

      // remove comments
      if (!inliner.options.preserveComments) {
        inliner.removeComments($(':root')[0], $);
      }

      // collapse the white space
      if (inliner.options.collapseWhitespace) {
        debug('collapsing whitespace');
        $('pre, textarea').each(function () {
          $(this).html($(this).html()
              .replace(/\n/g, '~~nl~~')
              .replace(/\s/g, '~~s~~'));
        });

        $('script').each(function () {
          $(this).text($(this).text()
              .replace(/\n/g, '~~nl~~')
              .replace(/\s/g, '~~s~~'));
        });

        html = $.html()
          .replace(/\s+/g, ' ')
          .replace(/~~nl~~/g, '\n')
          .replace(/~~s~~/g, ' ');
      } else {
        html = $.html();
      }

      debug('completed: %s bytes', html.length);

      return html;
    });

  })
  .then(function then(html) {
    inliner.callback(null, html);
    inliner.emit('end');
  })
  .catch(function errHandler(error) {
    debug('fail', error.stack);
    inliner.callback(error);
    inliner.emit('error', error);
    throw error;
  });
}
996982
def main(argument, sets, big_endian, optimal, output, clipboard,
         quiet, verbose):
    """"""
    logger = logging.getLogger()
    handler = logging.StreamHandler(sys.stderr)
    handler.setFormatter(LevelFormatter())
    logger.addHandler(handler)
    logger.setLevel(logging.WARNING + (quiet-verbose)*10)

    if sets and optimal:
        pat = Pat.from_chars(''.join(sets), optimal)
    elif optimal:
        pat = Pat.from_chars(optimal=optimal)
    elif sets:
        pat = Pat(sets)
    else:
        pat = Pat()

    if argument.isdigit():
        count = int(argument)
        try:
            pattern = pat.create(count)
        except IndexError:
            logging.exception(_('Failed to create the pattern.'))
            sys.exit(1)
        else:
            if output:
                output.write(pattern)
            elif clipboard:
                copy(pattern)
            else:
                print(pattern)
    else:
        target = argument
        try:
            index = pat.locate(target, big_endian)
        except KeyError:
            logging.exception(_('Failed to locate the pattern.'))
            sys.exit(1)
        else:
            print(index)

    sys.exit(0)
289584
def run(self):
        
        self.main_task.thread.start()
        self.main_task.thread.join()
1234174
public static void main(String[] args) {
        System.out.println("Hello World!");
        /*Executor exec = Executors.newCachedThreadPool();
        for(int i = 0; i < 20; i++) {
            final int v = i;
            exec.execute(new Runnable() {
                @Override
                public void run() {
                    System.out.println(v);
                }
            });
        }*/


        LongStream.rangeClosed(0, 5).map(n -> n * n).forEach(s -> System.out.print(s + " "));

    }
615208
def main(argv=None):
    """"""

    # If we're invoked directly (runwith ...), we'll get None here.
    if argv is None:
        argv = sys.argv[1:]

    # Parse command-line arguments.
    argv = cli.parse_args(argv)

    # Translate CLI arguments to Popen options.
    options = {}
    for k in ('stdin', 'stdout', 'stderr', 'cwd'):
        v = getattr(argv, k, None)
        if v:
            options[k] = v

    # Start the child process.
    try:
        process = subprocess.Popen(
            argv.command, **options
        )
    except OSError:
        print('Invalid command %r.' % argv.command)
        sys.exit(2)

    # Wait for the child process to complete.
    thread = threading.Thread(target=process.wait)
    thread.start()
    if argv.time_limit is None:
        thread.join()
    else:
        thread.join(argv.time_limit.total_seconds())
    if thread.is_alive() and argv.grace_time:
        process.send_signal(SIGKILL)
        thread.join(argv.grace_time.total_seconds())
    if thread.is_alive():
        process.terminate()
        thread.join()
    status = process.returncode
    assert status is not None

    # Forward exit code.
    return status
558267
async function main({ isFragment, needsHelp, showVersion, useTabs }) {
  /* eslint-disable no-console */
  const stdin = await getStdin()

  if (showVersion) {
    return console.log(version)
  }

  if (needsHelp || !stdin) {
    return console.log(help)
  }

  const pug = html2pug(stdin, { isFragment, useTabs })
  return console.log(pug)

  /* eslint-enable no-console */
}
520031
private final static Thread stdOut(final Process p) {
        final byte[] empty = new byte[128];
        for (int b = 0; b < empty.length; b++) {
            empty[b] = (byte) 0;
        }
        Thread std = new Thread() {
            public void run() {
                StringBuilder sb = new StringBuilder(1024);
                byte[] buf = new byte[128];
                BufferedInputStream bis = new BufferedInputStream(p.getInputStream());
                log.debug("Process output:");
                try {
                    while (bis.read(buf) != -1) {
                        sb.append(new String(buf).trim());
                        // clear buffer
                        System.arraycopy(empty, 0, buf, 0, buf.length);
                    }
                    log.debug(sb.toString());
                    bis.close();
                } catch (Exception e) {
                    log.error("{}", e);
                }
            }
        };
        std.setDaemon(true);
        std.start();
        return std;
    }
1356121
async function main() {
  const csv = fs.readFileSync('fsm.csv', { encoding: 'utf8' })
  const dot = graphViz(parseCSV(csv))
  fs.writeFileSync('fsm.dot', dot)
  const viz = new Viz({ Module, render })
  const svg = await viz.renderString(dot)
  fs.writeFileSync('fsm.svg', svg)
}
777959
def main():
    
    source_lines = (line.rstrip() for line in sys.stdin)
    console = InteractiveInterpreter()
    console.runsource('import turicreate')
    source = ''
    try:
        while True:
            source = source_lines.next()
            more = console.runsource(source)
            while more:
                next_line = source_lines.next()
                print '...', next_line
                source += '\n' + next_line
                more = console.runsource(source)
    except StopIteration:
        if more:
            print '... '
            more = console.runsource(source + '\n')
497356
def main():
    
    # Catch the CTRL-C signal
    signal.signal(signal.SIGINT, __signal_handler)

    # Log Glances and psutil version
    logger.info('Start Glances {}'.format(__version__))
    logger.info('{} {} and psutil {} detected'.format(
        platform.python_implementation(),
        platform.python_version(),
        psutil_version))

    # Share global var
    global core

    # Create the Glances main instance
    core = GlancesMain()
    config = core.get_config()
    args = core.get_args()

    # Glances can be ran in standalone, client or server mode
    start(config=config, args=args)
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, []);
}
304520
def cli(sequencepath, report, refseq_database):
    
    main(sequencepath, report, refseq_database, num_threads=multiprocessing.cpu_count())
268994
function() {
                // Force anything that is inlined onto the stack so we don't have duplication
                // when we examine local
                this.flushInline();
                var local = this.popStack();
                this.pushSource('if (' + local + ' != null) { ' + this.appendToBuffer(local) + ' }');
                if (this.environment.isSimple) {
                    this.pushSource("else { " + this.appendToBuffer("''") + " }");
                }
            }
700718
def main():
    
    buff = ''
    for line in fileinput.input():
        buff += line

    parser = jbossparser.JbossParser()
    result = parser.parse(buff)
    print(json.dumps(result))
422281
def threadpooled(
    func: None = None,
    *,
    loop_getter: typing.Union[None, typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop] = None,
    loop_getter_need_context: bool = False,
) -> ThreadPooled:
    """"""
301129
async function runProgram() {
    let argvFragment = process.argv.slice(2);
    if (argvFragment.length === 0) {
        argvFragment = ['-h'];
    }

    const latest = await latestVersion(pkg.name, {version: `>${pkg.version}`})
        .catch(() => pkg.version);
    if (semver.gt(latest, pkg.version)) {
        process.stderr.write(chalk.default.white(`\n     Update available `));
        process.stderr.write(chalk.default.grey(`${pkg.version}`));
        process.stderr.write(chalk.default.white(` -> `));
        process.stderr.write(chalk.default.greenBright(`${latest}\n`));
        process.stderr.write(chalk.default.white(`     Run `));
        process.stderr.write(chalk.default.blueBright(`npm i -g ${pkg.name} `));
        process.stderr.write(chalk.default.white(`to update.\n\n`));
    }

    args = minimist(argvFragment);

    if (args.prefix) {
        intercept(function (txt) {
            return `[${pkg.name}]\n${txt}`;
        });
    }

    if (args['!'] ||
        args.help ||
        args.h ||
        args._.includes('help')) {
        return help(args, process.stdout);
    }


    if (args._.length === 1 && args._[0] === 'init') {
        const result = await initializeConfig();
        if (result) {
            await stdoutAsync(`Successfully wrote ${process.cwd()}/.qnamakerrc\n`);
        }
        return;
    }

    if (args.version || args.v) {
        await stdoutAsync(require(path.join(__dirname, '../package.json')).version + '\n');
        return;
    }

    let serviceIn = {};
    if (args.stdin) {
        let json = await stdin();
        serviceIn = JSON.parse(json);
    }

    const config = await composeConfig(args);
    args.kbId = args.kbId || serviceIn.kbId || config.kbId;
    args.subscriptionKey = args.subscriptionKey || serviceIn.subscriptionKey || config.subscriptionKey;
    args.endpointKey = args.endpointKey || serviceIn.endpointKey || config.endpointKey;
    args.hostname = args.hostname || serviceIn.hostname || config.hostname;

    ServiceBase.config = args;

    validateConfig(args);

    if (args._[0] === 'set')
        return await handleSetCommand(args, config);

    const serviceManifest = getServiceManifest(args);

    let requestBody = await validateArguments(serviceManifest);

    // special case operations
    switch (serviceManifest.operation.methodAlias) {
        case 'delete':
            if (!args.f && !args.force) {
                let kbResult = await new Knowledgebase().getKnowledgebaseDetails(config);
                let kb = JSON.parse(await kbResult.text());
                if (!args.force) {
                    let answer = readlineSync.question(`Are you sure you would like to delete ${kb.name} [${kb.id}]? [no] `, {defaultInput: 'no'});
                    if (answer.trim()[0] === 'n') {
                        process.stderr.write('operation canceled');
                        return;
                    }
                }
            }
            break;

        case 'create':
            if (args.name)
                requestBody.name = args.name;

            if (!requestBody.name) {
                if (!(args.q || args.quiet)) {
                    let answer = readlineSync.question(`What would you like to name your new knowledgebase? `);
                    if (answer && answer.length > 0)
                        requestBody.name = answer.trim();
                }
            }
            // hack to map incorrect export property from expected import.  Export uses qnaDocuments, create/update/replace qnaList :(
            if (requestBody.qnaDocuments && !requestBody.qnaList) {
                requestBody.qnaList = requestBody.qnaDocuments;
                delete requestBody.qnaDocuments;
            }
            break;

        case 'replace':
        case 'update':
            // hack to map incorrect export property from expected.  Export uses qnaDocuments, create/update/replace qnaList :(
            if (requestBody.qnaDocuments && !requestBody.qnaList) {
                requestBody.qnaList = requestBody.qnaDocuments;
                delete requestBody.qnaDocuments;
            }
            break;
    }

    let result = await qnamaker(config, serviceManifest, args, requestBody);
    if (result.error) {
        throw new Error(JSON.stringify(result.error, null, 4));
    }

    // special case response
    switch (serviceManifest.operation.name) {
        case 'getKnowledgebaseDetails': {
            config.kbId = result.id;
            let kb = await updateKbId(config);
            if (args.msbot) {
                await stdoutAsync(JSON.stringify({
                    type: 'qna',
                    name: kb.name,
                    id: kb.id,
                    kbId: kb.id,
                    subscriptionKey: config.subscriptionKey,
                    endpointKey: config.endpointKey,
                    hostname: kb.hostName
                }, null, 2) + '\n');
            } else {
                await stdoutAsync(JSON.stringify(result, null, 2) + '\n');
            }
            break;
        }
        case 'createKnowledgebase':
            if (args.wait || args.msbot) {
                result = await waitForOperationSucceeded(config, result);

                let kbId = result.resourceLocation.split('/')[2];
                config.kbId = kbId;
                let kb = await updateKbId(config);
                if (args.msbot) {
                    await stdoutAsync(JSON.stringify({
                        type: 'qna',
                        name: kb.name,
                        id: kb.id,
                        kbId: kb.id,
                        subscriptionKey: config.subscriptionKey,
                        endpointKey: config.endpointKey,
                        hostname: config.hostname
                    }, null, 2) + '\n');

                } else {
                    await stdoutAsync(JSON.stringify(result, null, 2));
                }
                if (args.wait && !(args.q || args.quiet) && !args.msbot) {
                    let answer = readlineSync.question(`Would you like to save ${kb.name} ${kb.id} in your .qnamakerrc so that future commands will be with this KB? [yes] `, {defaultInput: 'yes'});
                    if (answer[0] === 'y') {
                        await fs.writeJson(path.join(process.cwd(), '.qnamakerrc'), config, {spaces: 2});
                        await stdoutAsync('.qnamakerrc updated' + '\n');
                    }
                }
            } else {
                await stdoutAsync(JSON.stringify(result, null, 2));
            }
            break;

        case 'updateKnowledgebase':
            if (args.wait || args.msbot) {
                result = await waitForOperationSucceeded(config, result);
            }
            await stdoutAsync(JSON.stringify(result, null, 2));
            break;

        default: {
            // dump json as json stringified
            if (typeof result === 'string')
                await stdoutAsync(result + '\n');
            else
                await stdoutAsync(JSON.stringify(result, null, 2) + '\n');
            break;
        }
    }
}
775873
public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					BootstrapWindow frame = new BootstrapWindow();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}