Protected API starts here
343982
protected function action($message, $level, $options = null) {
        $prefix = $this->get_prefix($level, $options);
        $depth = isset($options['depth']) ? $options['depth'] : 0;
        // Depending of the type (extension of the file), format differently
        if (substr($this->fullpath, -5) !== '.html') {
            $content = $prefix . str_repeat('  ', $depth) . $message . PHP_EOL;
        } else {
            $content = $prefix . str_repeat('&nbsp;&nbsp;', $depth) . htmlentities($message, ENT_QUOTES, 'UTF-8') . '<br/>' . PHP_EOL;
        }
        if (false === fwrite($this->fhandle, $content)) {
            throw new base_logger_exception('error_writing_file', $this->fullpath);
        }
        return true;
    }
605483
function begin(name, bypass) {
        _currentOperation = _getBase(name);
        if (bypass === true) {
            _currentOperation.bypass = true;
        }
    }
1186739
def initialize_api(args):
  
  global api
  api = ApiResource(server_host=args.hostname, server_port=args.port,
                    username=args.username, password=args.password,
                    version=args.api_version, use_tls=args.use_tls)
1339090
function(resource) {
    // If API discovery had any failures, calls to api info should redirect to the error page
    if (APIS_CFG.API_DISCOVERY_ERRORS) {
      var possibleCertFailure  = _.every(APIS_CFG.API_DISCOVERY_ERRORS, function(error){
        return _.get(error, "data.status") === 0;
      });
      if (possibleCertFailure && !AuthService.isLoggedIn()) {
        // will trigger a login flow which will redirect to the api server
        AuthService.withUser();
        return;
      }
      var fatal = false;
      _.each(APIS_CFG.API_DISCOVERY_ERRORS, function(discoveryError) {
        if (discoveryError.fatal) {
          Logger.error('API discovery failed (fatal error)', discoveryError);
          fatal = true;
          return;
        }

        Logger.warn('API discovery failed', discoveryError);
      });
      if (fatal) {
        // Go to the error page on fatal errors, the server might be down.
        // Can't use Navigate.toErrorPage or it will create a circular
        // dependency
        $window.location.href = URI('error').query({
          error_description: "Unable to load details about the server. If the problem continues, please contact your system administrator.",
          error: "API_DISCOVERY"
        }).toString();
        return;
      }
    }

    resource = toResourceGroupVersion(resource);
    var primaryResource = resource.primaryResource();
    var discoveredResource;
    // API info for resources in an API group, if the resource was not found during discovery return undefined
    if (resource.group) {
      discoveredResource = _.get(APIS_CFG, ["groups", resource.group, "versions", resource.version, "resources", primaryResource]);
      if (!discoveredResource) {
        return undefined;
      }
      var hostPrefixObj = _.get(APIS_CFG, ["groups", resource.group, 'hostPrefix']) || APIS_CFG;
      return {
        resource: resource.resource,
        group:    resource.group,
        version:  resource.version,
        protocol: hostPrefixObj.protocol,
        hostPort: hostPrefixObj.hostPort,
        prefix:   hostPrefixObj.prefix,
        namespaced: discoveredResource.namespaced,
        verbs: discoveredResource.verbs
      };
    }

    // Resources without an API group could be legacy k8s or origin resources.
    // Scan through resources to determine which this is.
    var api;
    for (var apiName in API_CFG) {
      api = API_CFG[apiName];
      discoveredResource = _.get(api, ["resources", resource.version, primaryResource]);
      if (!discoveredResource) {
        continue;
      }
      return {
        resource: resource.resource,
        version:  resource.version,
        hostPort: api.hostPort,
        prefix:   api.prefix,
        namespaced: discoveredResource.namespaced,
        verbs: discoveredResource.verbs
      };
    }
    return undefined;
  }
889412
async function main() {
  event.$emit('before-client-render')

  if (globalState.initialData) {
    dataStore.replaceState(globalState.initialData)
  }

  await routerReady(router)

  if (router.getMatchedComponents().length === 0) {
    throw new ReamError(pageNotFound(router.currentRoute.path))
  }
}
84823
public function start(): self
    {
        if (!$this->url) {
            throw new \RuntimeException("Please the property 'url' and 'saveAs'.", -1);
        }

        // default save to current dir.
        if (!$save = $this->saveAs) {
            $save = \getcwd() . '/' . \basename($this->url);
            // reset
            $this->saveAs = $save;
        }

        $ctx = \stream_context_create();

        // register stream notification callback
        \stream_context_set_params($ctx, [
            'notification' => [$this, 'progressShow']
        ]);

        Cli::write("Download: {$this->url}\nSave As: {$save}\n");

        $fp = \fopen($this->url, 'rb', false, $ctx);

        if (\is_resource($fp) && \file_put_contents($save, $fp)) {
            Cli::write("\nDone!");
        } else {
            $err = \error_get_last();
            Cli::stderr("\nErr.rrr..orr...\n {$err['message']}\n", true, -1);
        }

        // close resource
        if (\is_resource($fp)) {
            \fclose($fp);
        }

        $this->fileSize = null;
        return $this;
    }
652760
function start() {
    return __awaiter(this, void 0, void 0, function* () {
        yield __1.driver.connect();
        yield __1.driver.login({ username: config_1.botUser.username, password: config_1.botUser.password });
        yield __1.driver.subscribeToMessages();
        yield __1.driver.respondToMessages((err, msg, msgOpts) => {
            if (err)
                throw err;
            console.log('[respond]', JSON.stringify(msg), JSON.stringify(msgOpts));
            demo(msg).catch((e) => console.error(e));
        }, {
            rooms: ['general'],
            allPublic: false,
            dm: true,
            edited: true,
            livechat: false
        });
    });
}
131144
function init(endPoint, accessKeyId, accessKeySecret, securityToken = null, project) {
  return AliyunLog && AliyunLog.initAliyunLog && AliyunLog.initAliyunLog(endPoint, accessKeyId, accessKeySecret, securityToken, project);
}
994956
function _initialize() {

        var i, len, parts, tokens, moduleName, moduleObj, initialStates, initialState, currentStates, currentState, counter, hash;

        // Decode the content of our storage field...
        parts = _stateField.value.split("|");

        if (parts.length > 1) {

            initialStates = parts[0].split("&");
            for (i = 0, len = initialStates.length; i < len; i++) {
                tokens = initialStates[i].split("=");
                if (tokens.length === 2) {
                    moduleName = tokens[0];
                    initialState = tokens[1];
                    moduleObj = _modules[moduleName];
                    if (moduleObj) {
                        moduleObj.initialState = initialState;
                    }
                }
            }

            currentStates = parts[1].split("&");
            for (i = 0, len = currentStates.length; i < len; i++) {
                tokens = currentStates[i].split("=");
                if (tokens.length >= 2) {
                    moduleName = tokens[0];
                    currentState = tokens[1];
                    moduleObj = _modules[moduleName];
                    if (moduleObj) {
                        moduleObj.currentState = currentState;
                    }
                }
            }
        }

        if (parts.length > 2) {
            _fqstates = parts[2].split(",");
        }

        if (YAHOO.env.ua.ie) {

            if (typeof document.documentMode === "undefined" || document.documentMode < 8) {

                // IE < 8 or IE8 in quirks mode or IE7 standards mode
                _checkIframeLoaded();

            } else {

                // IE8 in IE8 standards mode
                YAHOO.util.Event.on(top, "hashchange",
                    function () {
                        var hash = _getHash();
                        _handleFQStateChange(hash);
                        _storeStates();
                    });

                _initialized = true;
                YAHOO.util.History.onLoadEvent.fire();

            }

        } else {

            // Start the thread that will have the responsibility to
            // periodically check whether a navigate operation has been
            // requested on the main window. This will happen when
            // YAHOO.util.History.navigate has been called or after
            // the user has hit the back/forward button.

            // On Safari 1.x and 2.0, the only way to catch a back/forward
            // operation is to watch history.length... We basically exploit
            // what I consider to be a bug (history.length is not supposed
            // to change when going back/forward in the history...) This is
            // why, in the following thread, we first compare the hash,
            // because the hash thing will be fixed in the next major
            // version of Safari. So even if they fix the history.length
            // bug, all this will still work!
            counter = history.length;

            // On Gecko and Opera, we just need to watch the hash...
            hash = _getHash();

            setInterval(function () {

                var state, newHash, newCounter;

                newHash = _getHash();
                newCounter = history.length;
                if (newHash !== hash) {
                    hash = newHash;
                    counter = newCounter;
                    _handleFQStateChange(hash);
                    _storeStates();
                } else if (newCounter !== counter && YAHOO.env.ua.webkit) {
                    hash = newHash;
                    counter = newCounter;
                    state = _fqstates[counter - 1];
                    _handleFQStateChange(state);
                    _storeStates();
                }

            }, 50);

            _initialized = true;
            YAHOO.util.History.onLoadEvent.fire();
        }
    }
847254
function api(){
  var _res = this;

  if(typeof(_res) != "object" && _is_not_has_prototype('end')){
    arguments = [];
    console.dir('not a object')
  }
  
  if (arguments.length == 1) {
    var http_code = 200;
    var api_data      = arguments[0];
    var api_status    = {
      code : 0,
      msg  : 'request success!'
    }
    
    return _api(http_code, api_data, api_status);
  } else if (arguments.length == 2) {
    var http_code = 200;
    var api_data      = arguments[0];
    var api_status    = arguments[1];
    
    return _api(http_code, api_data, api_status);
  } else if (arguments.length == 3) {
    var http_code = arguments[0];
    var api_data      = arguments[1];
    var api_status    = arguments[2];
    
    return _api(http_code, api_data, api_status);
  } else {
    var http_code = 200;
    var api_data      = {};
    var api_status    = {
      code : 222222222,
      msg  : 'res.api params error or res is not a express.response object!'
    }
    
    return _api(http_code, api_data, api_status);
  }
  
  function _is_not_has_prototype(name){
    console.dir(_res)
    return !_res.hasOwnProperty(name)&&(name in _res);
  }
  
  function _api (http_code, data, status) {
    if (_res.is_jsonp && _res.is_jsonp == true) {
      return _res.status(http_code).jsonp({
        data    : data,
        status  : status
      })
    } else {
      return _res.status(http_code).json({
        data    : data,
        status  : status
      })
    }
  }
}
1357945
function buildStartCmd (startAppOptions, apiLevel) {
  let cmd = ['am', 'start'];
  if (util.hasValue(startAppOptions.user)) {
    cmd.push('--user', startAppOptions.user);
  }
  cmd.push('-W', '-n', `${startAppOptions.pkg}/${startAppOptions.activity}`);
  if (startAppOptions.stopApp && apiLevel >= 15) {
    cmd.push('-S');
  }
  if (startAppOptions.action) {
    cmd.push('-a', startAppOptions.action);
  }
  if (startAppOptions.category) {
    cmd.push('-c', startAppOptions.category);
  }
  if (startAppOptions.flags) {
    cmd.push('-f', startAppOptions.flags);
  }
  if (startAppOptions.optionalIntentArguments) {
    // expect optionalIntentArguments to be a single string of the form:
    //     "-flag key"
    //     "-flag key value"
    // or a combination of these (e.g., "-flag1 key1 -flag2 key2 value2")

    // take a string and parse out the part before any spaces, and anything after
    // the first space
    let parseKeyValue = function (str) {
      str = str.trim();
      let space = str.indexOf(' ');
      if (space === -1) {
        return str.length ? [str] : [];
      } else {
        return [str.substring(0, space).trim(), str.substring(space + 1).trim()];
      }
    };

    // cycle through the optionalIntentArguments and pull out the arguments
    // add a space initially so flags can be distinguished from arguments that
    // have internal hyphens
    let optionalIntentArguments = ` ${startAppOptions.optionalIntentArguments}`;
    let re = / (-[^\s]+) (.+)/;
    while (true) { // eslint-disable-line no-constant-condition
      let args = re.exec(optionalIntentArguments);
      if (!args) {
        if (optionalIntentArguments.length) {
          // no more flags, so the remainder can be treated as 'key' or 'key value'
          cmd.push.apply(cmd, parseKeyValue(optionalIntentArguments));
        }
        // we are done
        break;
      }

      // take the flag and see if it is at the beginning of the string
      // if it is not, then it means we have been through already, and
      // what is before the flag is the argument for the previous flag
      let flag = args[1];
      let flagPos = optionalIntentArguments.indexOf(flag);
      if (flagPos !== 0) {
        let prevArgs = optionalIntentArguments.substring(0, flagPos);
        cmd.push.apply(cmd, parseKeyValue(prevArgs));
      }

      // add the flag, as there are no more earlier arguments
      cmd.push(flag);

      // make optionalIntentArguments hold the remainder
      optionalIntentArguments = args[2];
    }
  }
  return cmd;
}
425111
def start(self, serve=[]):
        """"""

        # Check arguments
        if type(serve) is str:
            serve = [serve]
        elif type(serve) is list:
            pass
        else:
            raise Exception("'serve' should be an api name or a list of api names")

        if len(serve) == 0:
            raise Exception("You must specify at least one api to serve")

        for api_name in serve:
            if api_name not in self.apis:
                raise Exception("Can't find %s.yaml (swagger file) in the api directory %s" % (api_name, self.path_apis))

        app = self.app
        app.secret_key = os.urandom(24)

        # Initialize JWT config
        conf = get_config()
        if hasattr(conf, 'jwt_secret'):
            log.info("Set JWT parameters to issuer=%s audience=%s secret=%s***" % (
                conf.jwt_issuer,
                conf.jwt_audience,
                conf.jwt_secret[0:8],
            ))

        # Always serve the ping api
        serve.append('ping')

        # Let's compress returned data when possible
        compress = Compress()
        compress.init_app(app)

        # All apis that are not served locally are not persistent
        not_persistent = []
        for api_name in self.apis.keys():
            if api_name in serve:
                pass
            else:
                not_persistent.append(api_name)

        # Now load those apis into the ApiPool
        for api_name, api_path in self.apis.items():

            host = None
            port = None

            if api_name in serve:
                # We are serving this api locally: override the host:port specified in the swagger spec
                host = self.host
                port = self.port

            do_persist = True if api_name not in not_persistent else False
            local = True if api_name in serve else False

            log.info("Loading api %s from %s (persist: %s)" % (api_name, api_path, do_persist))
            ApiPool.add(
                api_name,
                yaml_path=api_path,
                timeout=self.timeout,
                error_callback=self.error_callback,
                formats=self.formats,
                do_persist=do_persist,
                host=host,
                port=port,
                local=local,
            )

        ApiPool.merge()

        # Now spawn flask routes for all endpoints
        for api_name in self.apis.keys():
            if api_name in serve:
                log.info("Spawning api %s" % api_name)
                api = getattr(ApiPool, api_name)
                # Spawn api and wrap every endpoint in a crash handler that
                # catches replies and reports errors
                api.spawn_api(app, decorator=generate_crash_handler_decorator(self.error_decorator))

        log.debug("Argv is [%s]" % '  '.join(sys.argv))
        if 'celery' in sys.argv[0].lower():
            # This code is loading in a celery server - Don't start the actual flask app.
            log.info("Running in a Celery worker - Not starting the Flask app")
            return

        # Initialize monitoring, if any is defined
        monitor_init(app=app, config=conf)

        if os.path.basename(sys.argv[0]) == 'gunicorn':
            # Gunicorn takes care of spawning workers
            log.info("Running in Gunicorn - Not starting the Flask app")
            return

        # Debug mode is the default when not running via gunicorn
        app.debug = self.debug

        app.run(host='0.0.0.0', port=self.port)
659522
static function init()
  {
    if (self::$initialized) return;

    self::$initialized = TRUE;

    self::$COFFEE_KEYWORDS  = array_merge(self::$COFFEE_KEYWORDS, array_keys(self::$COFFEE_ALIASES));
    self::$COFFEE_RESERVED  = array_merge(self::$JS_RESERVED, self::$JS_KEYWORDS, self::$COFFEE_KEYWORDS, self::$STRICT_PROSCRIBED);
    self::$JS_FORBIDDEN     = array_merge(self::$JS_KEYWORDS, self::$JS_RESERVED, self::$STRICT_PROSCRIBED);
    self::$INDEXABLE        = array_merge(self::$CALLABLE, self::$INDEXABLE);
    self::$NOT_SPACED_REGEX = array_merge(self::$NOT_REGEX, self::$NOT_SPACED_REGEX);

    Rewriter::init();

    self::$INVERSES         = Rewriter::$INVERSES;
  }
126169
def load_api_context(cls, api_context):
        

        cls._api_context = api_context
        cls._user_context = UserContext(api_context.session_context.user_id)
        cls._user_context.init_main_monetary_account()
710766
function pin() {
        return (new \React\Promise\Promise(function (callable $resolve, callable $reject) {
            $this->client->apimanager()->endpoints->channel->pinChannelMessage($this->channel->getId(), $this->id)->done(function () use ($resolve) {
                $resolve($this);
            }, $reject);
        }));
    }
994105
private function startList()
    {
        $list = new ArrayObject();

        if (null === ($key = $this->tokens->getKey())) {
            $this->current[] = $list;
        } else {
            $this->current[$key] = $list;
        }

        $this->stack[] = $this->current;
        $this->current = $list;
    }
146700
private static function init() {
        self::$appContext = new AppContext(self::$config);

        if (isset(self::$config['customHandlers'])) {
            if (is_callable(self::$config['customHandlers'])) {
                call_user_func(self::$config['customHandlers'], self::$appContext);
            }
            else {
                throw new \Exception('Function is expected.');
            }
        }

        self::invokeAll(self::$appContext->getPreInit(), array(self::$appContext));

        $config = self::$appContext->getConfig();

        if (empty($config['appNamespace'])) {
            throw new \Exception('The root namespace for the application is required. To specify the namespace of your application, use the useNamespace method. The value must not be null or empty.');
        }

        if (empty($config['basePath'])) {
            $config['basePath'] = getcwd();
        }

        if (!defined('PHPMVC_DS')) { define('PHPMVC_DS', DIRECTORY_SEPARATOR); }
        if (!defined('PHPMVC_ROOT_PATH')) { define('PHPMVC_ROOT_PATH', $config['basePath'] . PHPMVC_DS); }
        if (!defined('PHPMVC_CORE_PATH')) { define('PHPMVC_CORE_PATH', __DIR__ .PHPMVC_DS); }
        if (!defined('PHPMVC_CONFIG_PATH')) { define('PHPMVC_CONFIG_PATH', PHPMVC_ROOT_PATH . 'config' . PHPMVC_DS); }
        if (!defined('PHPMVC_FILTER_PATH')) { define('PHPMVC_FILTER_PATH', PHPMVC_ROOT_PATH . 'filters' . PHPMVC_DS); }
        if (!defined('PHPMVC_CONTROLLER_PATH')) { define('PHPMVC_CONTROLLER_PATH', PHPMVC_ROOT_PATH . 'controllers' . PHPMVC_DS); }
        if (!defined('PHPMVC_MODEL_PATH')) { define('PHPMVC_MODEL_PATH', PHPMVC_ROOT_PATH . 'models' . PHPMVC_DS); }
        if (!defined('PHPMVC_VIEW_PATH')) { define('PHPMVC_VIEW_PATH', PHPMVC_ROOT_PATH . 'views' . PHPMVC_DS); }
        if (!defined('PHPMVC_SHARED_PATH')) { define('PHPMVC_SHARED_PATH', PHPMVC_VIEW_PATH . 'shared' . PHPMVC_DS); }
        if (!defined('PHPMVC_UPLOAD_PATH')) { define('PHPMVC_UPLOAD_PATH', PHPMVC_ROOT_PATH . 'upload' . PHPMVC_DS); }

        if (!defined('PHPMVC_APP_NAMESPACE')) {
            define('PHPMVC_APP_NAMESPACE', $config['appNamespace']);
        }
        elseif (PHPMVC_APP_NAMESPACE !== $config['appNamespace']) {
            throw new \Exception('Constant PHPMVC_CONTROLLER already defined. Re-define with other value is not possible.');
        }

        if (empty($config['routeProvider'])) {
            $config['routeProvider'] = new DefaultRouteProvider();
        }
        elseif (!$config['routeProvider'] instanceof RouteProvider) {
            throw new \Exception('The routeProvider type must be the base of "\PhpMvc\RouteProvider".');
        }

        $config['routeProvider']->init();

        if (isset($config['routes'])) {
            if (is_callable($config['routes'])) {
                $config['routes']($config['routeProvider']);
            }
            elseif (is_array($config['routes'])) {
                $provider = $config['routeProvider'];

                foreach($config['routes'][0] as $route) {
                    $provider->add($route->name, $route->template, $route->defaults, $route->constraints);
                }

                if (count($config['routes']) > 1) {
                    foreach($config['routes'][1] as $route) {
                        $provider->ingnore($route->template, $route->constraints);
                    }
                }
            }
            elseif ($config['routes'] instanceof RouteCollection) {
                $provider = $config['routeProvider'];

                foreach($config['routes'] as $route) {
                    $provider->add($route->name, $route->template, $route->defaults, $route->constraints);
                }
            }
        }

        if (empty($config['cacheProvider'])) {
            $config['cacheProvider'] = new IdleCacheProvider();
        }
        elseif (!$config['cacheProvider'] instanceof CacheProvider) {
            throw new \Exception('The $cacheProvider type must be the base of "\PhpMvc\CacheProvider".');
        }

        $config['cacheProvider']->init();

        if (isset($config['sessionProvider'])) {
            if ($config['sessionProvider'] === true) {
                $config['sessionProvider'] = new HttpSession();
            }
            elseif (!$config['sessionProvider'] instanceof HttpSessionProvider) {
                throw new \Exception('The $sessionProvider type must be the base of "\PhpMvc\HttpSessionProvider".');
            }

            $config['sessionProvider']->init();
        }

        if (empty($config['httpContext'])) {
            $info = new HttpContextInfo();
            $info->routeProvider = $config['routeProvider'];
            $info->cacheProvider = $config['cacheProvider'];
            $info->request = new HttpRequest();
            $info->response = new HttpResponse();
            $info->session = isset($config['sessionProvider']) ? $config['sessionProvider'] : null;

            $config['httpContext'] = new HttpContext($info);
        }
        elseif (!$config['httpContext'] instanceof HttpContextBase) {
            throw new \Exception('The httpContext type must be the base of "\PhpMvc\HttpContextBase".');
        }

        // default response handlers
        $response = $config['httpContext']->getResponse();

        $response->setEndHandler(function() use ($config) {
            self::invokeAll(self::$appContext->getEnd(), array(new ActionContext($config['httpContext'])));
        });

        $response->setPreSendHandler(function() use ($config) {
            self::invokeAll(self::$appContext->getPreSend(), array(new ActionContext($config['httpContext'])));
        });

        // set context and config, and invoke init handlers
        InternalHelper::setStaticPropertyValue('\\PhpMvc\\HttpContext', 'current', $config['httpContext']);

        self::$appContext->setConfig($config);
        self::invokeAll(self::$appContext->getInit(), array(self::$appContext));
        self::$config = self::$appContext->getConfig();
    }