Initialization before prompting user for commands.

        Despite the claims in the Cmd documentaion, Cmd.preloop() is not a stub
517087
def preloop(self):
        
        Cmd.preloop(self)    # sets up command completion
        self._hist = []    # No history yet
        self._locals = {}    # Initialize execution namespace for user
        self._globals = {}
96825
function init(userOpts = {}) {
    const opts = Object.assign(
        {
            template: '[hash].[ext][query]',
            preservePath: false,
            hashFunction(contents) {
                return crypto
                    .createHash('sha1')
                    .update(contents)
                    .digest('hex')
                    .substr(0, 16);
            },
            transform(fileMeta) {
                return fileMeta;
            },
            ignore: []
        },
        userOpts
    );

    return (style, result) => {
        if (opts.basePath) {
            if (typeof opts.basePath === 'string') {
                opts.basePath = [path.resolve(opts.basePath)];
            } else {
                opts.basePath = opts.basePath.map(elem => path.resolve(elem));
            }
        } else {
            opts.basePath = [process.cwd()];
        }

        if (opts.dest) {
            opts.dest = path.resolve(opts.dest);
        } else {
            throw new Error('Option `dest` is required in postcss-copy');
        }

        const promises = [];
        style.walkDecls(decl => {
            if (decl.value && decl.value.indexOf('url(') > -1) {
                promises.push(processDecl(result, decl, opts));
            }
        });
        return Promise.all(promises).then(decls =>
            decls.forEach(decl => {
                decl.value = String(decl.value);
            })
        );
    };
}
21836
def pre(self, command, output_dir, kw):
        
        # Build a random secret_key
        chars = u'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
        kw['secret_key'] = ''.join([ choice(chars) for i in range(50) ])

        # Paste version
        kw['epaster_template_name'] = u'emencia-paste-djangocms-3'
        kw['epaster_template_version'] = template_version
385082
private void initGui() {
        totalThreads.setText("100");
        initialDelay.setText("0");
        incUserCount.setText("10");
        incUserCountBurst.setText("0");
        incUserPeriod.setText("30");
        flightTime.setText("60");
        decUserCount.setText("5");
        decUserPeriod.setText("1");
        rampUp.setText("5");
    }
95058
def init(options, use_sigterm_handler=True):
    
    # pylint: disable-msg=W0613
    global _AUTH, _OPTIONS

    if isinstance(options, dict):
        _OPTIONS = DEFAULT_OPTIONS.copy()
        _OPTIONS.update(options)
    else:
        for optname, optvalue in DEFAULT_OPTIONS.iteritems():
            if hasattr(options, optname):
                _OPTIONS[optname] = getattr(options, optname)
            else:
                _OPTIONS[optname] = optvalue

    if _OPTIONS['testmethods']:
        def fortytwo(request):
            "test GET method"
            return 42
        def ping(request):
            "test POST method"
            return request.payload_params()
        register(fortytwo, 'GET')
        register(ping, 'POST')

    if _OPTIONS['auth_basic_file']:
        _AUTH = HttpAuthentication(_OPTIONS['auth_basic_file'],
                                   realm = _OPTIONS['auth_basic']).parse_file()

    for name, cmd in _COMMANDS.iteritems():
        if cmd.safe_init:
            LOG.info("safe_init: %r", name)
            cmd.safe_init(_OPTIONS)

    if use_sigterm_handler:
        # signal.signal(signal.SIGHUP, lambda *x: None) # XXX
        signal.signal(signal.SIGTERM, sigterm_handler)
        signal.signal(signal.SIGINT, sigterm_handler)
236025
def init_cli(self):
        
        if self.init_cli_cmds is None:
            self.init_cli_cmds = self.set_default_init_cli_cmds()

        for cli_cmd in self.init_cli_cmds:
            if isinstance(cli_cmd, list) and len(cli_cmd) >= 2:
                asynchronous = cli_cmd[1]
                if len(cli_cmd) > 2:
                    wait = cli_cmd[2]
                else:
                    wait = True
                self.execute_command(cli_cmd[0], wait=wait, asynchronous=asynchronous)
            else:
                self.execute_command(cli_cmd)
1278718
private void initStandardCommands() {
		finishCommand = new ActionCommand(getFinishCommandId()) {
			public void doExecuteCommand() {
				boolean result = onFinish();
				if (result) {
					if (getDisplayFinishSuccessMessage()) {
						showFinishSuccessMessageDialog();
					}
					executeCloseAction();
				}
			}
		};
		finishCommand.setSecurityControllerId(getFinishSecurityControllerId());
		finishCommand.setEnabled(defaultEnabled);

		cancelCommand = new ActionCommand(getCancelCommandId()) {

			public void doExecuteCommand() {
				onCancel();
			}
		};
	}
368594
private int init(String[] args) {
		try { // initialize file system handle
			fs = FileSystem.get(getConf());
		} catch (IOException ioe) {
			System.err.println("Can not initialize the file system: "
					+ ioe.getLocalizedMessage());
			return -1;
		}

		for (int i = 0; i < args.length; i++) { // parse command line
			if (args[i].equals("-root")) {
				root = new Path(args[++i]);
			} else if (args[i].equals("-inDir")) {
				inDir = new File(args[++i]);
			} else if (args[i].equals("-files"))
				nFiles = Integer.parseInt(args[++i]);
			else {
				System.err.println(USAGE);
				ToolRunner.printGenericCommandUsage(System.err);
				System.exit(-1);
			}
		}
		return 0;
	}
823320
function initializeCommands() {
        CommandManager.register(Strings.CMD_TOGGLE_PURE_CODE, CMD_TOGGLE_PURE_CODE, _togglePureCode);
        CommandManager.register(Strings.CMD_TOGGLE_PANELS, CMD_TOGGLE_PANELS, _togglePanels);

        Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(CMD_TOGGLE_PANELS, "", Menus.AFTER, Commands.VIEW_HIDE_SIDEBAR);
        Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(CMD_TOGGLE_PURE_CODE, "", Menus.AFTER, CMD_TOGGLE_PANELS);

        KeyBindingManager.addBinding(CMD_TOGGLE_PURE_CODE, [ {key: togglePureCodeKey}, {key: togglePureCodeKeyMac, platform: "mac"} ]);

        //default toggle panel shortcut was ctrl+shift+` as it is present in one vertical line in the keyboard. However, we later learnt
        //from IQE team than non-English keyboards does not have the ` char. So added one more shortcut ctrl+shift+1 which will be preferred
        KeyBindingManager.addBinding(CMD_TOGGLE_PANELS, [ {key: togglePanelsKey}, {key: togglePanelsKeyMac, platform: "mac"} ]);
        KeyBindingManager.addBinding(CMD_TOGGLE_PANELS, [ {key: togglePanelsKey_EN}, {key: togglePanelsKeyMac_EN, platform: "mac"} ]);
    }
795133
def init(runlevel):
    '''
    
    '''
    cmd = ['init', '{0}'.format(runlevel)]
    ret = __salt__['cmd.run'](cmd, python_shell=False)
    return ret
442198
private void initialize(){
		if(config.commandLogging){
			Log.d(config.commandLoggingTag, "initialize()");
		}
		
		Timeout.setLargeTimeout(initializeTimeout("solo_large_timeout", config.timeout_large));
		Timeout.setSmallTimeout(initializeTimeout("solo_small_timeout", config.timeout_small));
	}
129176
def init(argv):
    
    # Setting initial configuration values
    config.set_default({
        # driver section
        "driver": {},
        # fs section
        "fs": {},
        # MongoDB section
        "mongodb": {},
    })

    # Parse the command line
    init_parsecmdline(argv[1:])

    # Initiatize the output directory
    fs.init(dry_run=_opt["dry_run"], **config.get_entry('fs'))

    # This baby will handle UNIX signals
    signal.signal(signal.SIGINT,  _handle_signal)
    signal.signal(signal.SIGTERM, _handle_signal)
734061
function _preCommand(commands) {
  commander.on('--help', function () {

    var hasExample = _.map(_.values(commands), 'examples')
      .filter(function (elem) {
        return elem !== undefined;
      });
    if (hasExample.length > 0) {
      hasExample = hasExample.reduce(function (a, b) {
        return a.concat(b);
      });
    }
    hasExample = hasExample.length > 0;

    if (hasExample) {

      console.log('  Examples:\n');

      Object.keys(commands).forEach(function (command) {
        if (!_.isEmpty(commands[command].examples)) {
          console.log('    %s:', command);
          commands[command].examples.forEach(function (example) {
            console.log('      %s', example);
          });
        }
      });
    }
  });
}
828512
def preloop(self):
        """"""
        lines = textwrap.dedent(self.banner).split("\n")
        for line in lines:
            Console._print("BLUE", "", line)
78895
def init_command(self, action, flags=None):
    '''
    '''

    if not isinstance(action, list):
        action = [action]      
    cmd = ['singularity'] + action

    if self.quiet is True:
        cmd.insert(1, '--quiet')
    if self.debug is True:
        cmd.insert(1, '--debug')

    return cmd
1187756
def loop(self, intro=None):
        
        self.fire("preloop")
        if intro is not None:
            self.intro = intro
        if self.intro is not None:
            self.stdout.write(self.intro + "\n")
            self.stdout.flush()
        stop = None
        while not stop:
            if self.use_rawinput:
                try:
                    line = self.inputter(self.prompt)
                except EOFError:
                    line = self._eof
            else:
                self.stdout.write(self.prompt)
                self.stdout.flush()
                line = self.stdin.readline()
                if not len(line):
                    line = self._eof
                else:
                    line = line.rstrip("\r\n")
            line = self.fire("precmd", line)
            stop, results = self.onecmd(line)
            stop, results = self.fire("postcmd", stop, results, line)
        self.fire("postloop")
394086
public void init()
        throws ServletException
    {
        _env= new EnvList();
        _cmdPrefix=getInitParameter("commandPrefix");

        String tmp = getInitParameter("cgibinResourceBase");
        if (tmp==null)
            tmp = getServletContext().getRealPath("/");

        if(log.isDebugEnabled())log.debug("CGI: CGI bin "+tmp);

        if (tmp==null)
        {
            log.warn("CGI: no CGI bin !");
            throw new ServletException();
        }

        File dir = new File(tmp);
        if (!dir.exists())
        {
            log.warn("CGI: CGI bin does not exist - "+dir);
            throw new ServletException();
        }

        if (!dir.canRead())
        {
            log.warn("CGI: CGI bin is not readable - "+dir);
            throw new ServletException();
        }

        if (!dir.isDirectory())
        {
            log.warn("CGI: CGI bin is not a directory - "+dir);
            throw new ServletException();
        }

        try
        {
            _docRoot=dir.getCanonicalFile();
            if(log.isDebugEnabled())log.debug("CGI: CGI bin accepted - "+_docRoot);
        }
        catch (IOException e)
        {
            log.warn("CGI: CGI bin failed - "+dir);
            e.printStackTrace();
            throw new ServletException();
        }

        _path=getInitParameter("Path");
        if(log.isDebugEnabled())log.debug("CGI: PATH accepted - "+_path);
        if (_path != null)
            _env.set("PATH", _path);

        Enumeration e= getInitParameterNames();
        while (e.hasMoreElements())
        {
            String n= (String)e.nextElement();
            if (n != null && n.startsWith("ENV_"))
                _env.set(n.substring(4),getInitParameter(n));
        }
    }