Read the app from the current directory.
486448
function readApp(next) {
    jitsu.package.read(process.cwd(), function (err, pkg) {
      if (err) {
        callback(err);
      }

      name = pkg.name;
      next();
    });
  }
213657
def read(self, context, cmd_args):
	
		
		
		try:
			current_dir = os.getcwd()
			os.chdir(context.resolve(self.__config_dir))
			args = []
			args.extend(cmd_args)
			args.append(context.resolve(self.__name))
			yield from super().read(args)
		finally:
			os.chdir(current_dir)
1108661
def _read_from_paths():
    
    home = os.environ.get("HOME", "/")
    home_path = os.path.join(home, _SETTINGS_PATH)
    etc_path = os.path.join("/etc", _SETTINGS_PATH)

    read_path = None
    if home and os.path.exists(home_path):
        read_path = home_path
    elif os.path.exists(etc_path):
        read_path = etc_path

    if read_path:
        with open(read_path) as f:
            _substitute_globals(
                json.loads(f.read())
            )
666458
def _read_apps(self):
        
        apps = {}
        for cfgfile in glob.iglob(os.path.join(self.confdir, '*.conf')):
            name = os.path.basename(cfgfile)[0:-5]
            try:
                app = AppLogParser(name, cfgfile, self.args, self.logdir,
                                   self.fields, self.name_cache, self.report)
            except (LogRaptorOptionError, LogRaptorConfigError, LogFormatError) as err:
                logger.error('cannot add app %r: %s', name, err)
            else:
                apps[name] = app

        if not apps:
            raise LogRaptorConfigError('no configured application in %r!' % self.confdir)
        return apps
1248865
def read_file(self, file_path):
        '''  '''
        getLogger().info("Loading app config from {} file: {}".format(self.__mode, file_path))
        if self.__mode == AppConfig.JSON:
            return json.loads(FileHelper.read(file_path), object_pairs_hook=OrderedDict)
        elif self.__mode == AppConfig.INI:
            config = configparser.ConfigParser(allow_no_value=True)
            config.read(file_path)
            return config
1147734
function(callback) {
      var t = this,
          dirs = [],
          pages = [],
          thisAppName = UI.Server.currentServer.thisAppName;
      callback = callback || function(){};

      // Synchronize the virtual /app directory
      if (t.get('path') === '/app') {
        for (var appName in UI.Server.currentServer.apps) {
          // Don't add me to the /app directory if I'm an app
          if (appName !== thisAppName) {
            var app = UI.Server.currentServer.apps[appName];
            dirs.push({
              id: appName,
              label: app.label || app.description || appName,
              path: Path.join(app.moduleDir, 'site_db', t.CONST.objectClass)
            });
          }
        }

        // Trim directory branches that have no contents
        t.trimDirs(dirs, function(error, trimmed) {
          if (error) {
            callback(error);
          }
          t.set({
            leaves: pages,
            branches: trimmed
          });
          return callback();
        });
        return;
      }

      // Get the directory at this level
      FS.readdir(t.dirPath, function(error, fileNames) {

        // Process errors
        if (error) {
          console.error('TreeProbe readdir error', error);
          return callback(error);
        }

        // Don't show the main 404 page (it's too confusing)
        if (t.CONST.objectClass === 'Page') {
          fileNames = _.reject(fileNames, function(name){
            return name === '404.json';
          });
        }

        // Perform a stat on all files for meta-info
        t.statFiles(fileNames, function(error, fileStats) {

          // Process errors
          if (error) {
            console.error('TreeProbe statFiles error', error);
            return callback(error);
          }

          // Process each file, recording directories and pages
          for (var i = 0, l = fileStats.length; i < l; i++) {
            var name = fileNames[i],
                stat = fileStats[i],
                id = Path.basename(name, '.json'),
                page = {id:id};

            if (stat.isDirectory()) {
              page.path = Path.join(t.dirPath, name);
              dirs.push(page);
            }
            else if (stat.isFile() && Path.extname(name).toLowerCase() === '.json') {
              pages.push(page);
            }
            else {
              console.error('Not a file or directory: ' + name);
            }
          }

          // Read each page for the display label and description
          t.readPages(pages, function(error) {

            // Process errors
            if (error) {
              console.error('PagesProbe readPages error', error);
              return callback(error);
            }

            // Add the virtual /app directory to the root
            if (t.dirPath === t.rootPath) {
              dirs.push({
                id:'app',
                label: t.CONST.appLabel,
                description: t.CONST.appDescription,
                path: Path.dirname(t.dirPath)
              });
            }

            // Trim directory branches that have no contents
            t.trimDirs(dirs, function(error, trimmed) {
              if (error) {
                callback(error);
              }

              t.set({
                leaves: pages,
                branches: trimmed
              });
              return callback();
            });
          });

        });
      });

    }
1136299
function resolveApp(dir) {
  if (path.isAbsolute(dir)) return dir;
  return path.join(process.cwd(), dir);
}
685285
def collect(self):
        """"""
        for app_name, tools_path in get_apps_tools().items():
            self.stdout.write("Copying files from '{}'.".format(tools_path))

            app_name = app_name.replace('.', '_')

            app_destination_path = os.path.join(self.destination_path, app_name)
            if not os.path.isdir(app_destination_path):
                os.mkdir(app_destination_path)

            for root, dirs, files in os.walk(tools_path):
                for dir_name in dirs:
                    dir_source_path = os.path.join(root, dir_name)
                    dir_destination_path = self.change_path_prefix(
                        dir_source_path, tools_path, self.destination_path, app_name
                    )

                    if not os.path.isdir(dir_destination_path):
                        os.mkdir(dir_destination_path)

                for file_name in files:
                    file_source_path = os.path.join(root, file_name)
                    file_destination_path = self.change_path_prefix(
                        file_source_path, tools_path, self.destination_path, app_name
                    )

                    shutil.copy2(file_source_path, file_destination_path)
321444
def get_app(self, reference_app=None):
        """"""

        if reference_app is not None:
            return reference_app

        if current_app:
            return current_app._get_current_object()

        if self.app is not None:
            return self.app

        raise RuntimeError(
            'No application found. Either work inside a view function or push'
            ' an application context. See'
            ' http://flask-sqlalchemy.pocoo.org/contexts/.'
        )
1238475
def load_fis(dir=None):
    """"""
    if dir is None:
        import tkFileDialog
        try:
            dir=tkFileDialog.askdirectory()
        except:
            return
    if dir is None:
        return None
    from os.path import walk
    walk(dir,fits_list,"*.fits")
464814
def _handle_browse(self, relpath, params):
    """"""
    abspath = os.path.normpath(os.path.join(self._root, relpath))
    if not abspath.startswith(self._root):
      raise ValueError  # Prevent using .. to get files from anywhere other than root.
    if os.path.isdir(abspath):
      self._serve_dir(abspath, params)
    elif os.path.isfile(abspath):
      self._serve_file(abspath, params)
701267
def check_empty_app_dir(self):
        """"""
        if not os.listdir(self.app_path):
            self.handle_error(
                'No app exists in this directory. Try using "tcinit --template '
                '{} --action create" to create an app.'.format(self.args.template)
            )
1063336
def read_env(path=None, environ=None, recurse=True):
    
    environ = environ if environ is not None else os.environ

    # By default, start search from the same file this function is called
    if path is None:
        frame = inspect.currentframe().f_back
        caller_dir = os.path.dirname(frame.f_code.co_filename)
        path = os.path.join(os.path.abspath(caller_dir), ENV)
    if recurse:
        current = path
        pardir = os.path.abspath(os.path.join(current, os.pardir))
        while current != pardir:
            target = os.path.join(current, ENV)
            if os.path.exists(target):
                path = os.path.abspath(target)
                break
            else:
                current = os.path.abspath(os.path.join(current, os.pardir))
                pardir = os.path.abspath(os.path.join(current, os.pardir))
        if not path:
            raise FileNotFoundError('Could not find a .env file')

    with open(path, 'r') as fp:
        content = fp.read()
    parsed = parse_env(content)
    for key, value in parsed.items():
        environ.setdefault(key, value)
988692
def load_manifest(app, filename='manifest.json'):
    ''''''
    if os.path.isabs(filename):
        path = filename
    else:
        path = pkg_resources.resource_filename(app, filename)
    with io.open(path, mode='r', encoding='utf8') as stream:
        data = json.load(stream)
    _registered_manifests[app] = path
    return data
66604
def load_dir(self, path):
        

        def visit_path(arg, dirname, names):
            for name in names:
                fpath = os.path.join(dirname, name)
                new_path = fpath[len(path):]
                if os.path.isfile(fpath):
                    content = open(fpath, "rb").read()
                    self.touch(new_path, content)
                else:
                    self.mkdir(new_path)

        os.path.walk(path, visit_path, None)
1269101
def app_view(name, **kwargs):
    
    ctx = Context(**kwargs)
    ctx.execute_action('app:view', **{
        'storage': ctx.repo.create_secure_service('storage'),
        'name': name,
    })
639866
def path(self):
        """"""

        if not isinstance(self.ref, str):
            return None

        u = parse_app_url(self.ref)

        if u.inner.proto != 'file':
            return None

        return u.path