Returns the name of the main application from the given ini file. See
    :function:`app_name_from_ini_parser` for details.

    :param ini_file_path: Path to the .ini file to parse.
350580
def app_name_from_ini_file(ini_file_path):
    
    parser = configparser.SafeConfigParser()
    parser.read(ini_file_path)
    return app_name_from_ini_parser(parser)
820068
def index_from_filename(self, path):
        
        if path:
            for i in range(self.count()):
                widget = self.widget(i)
                try:
                    if widget.file.path == path:
                        return i
                except AttributeError:
                    pass  # not an editor widget
        return -1
948418
public static function LoadCache ($ini_path, $cache_file_path) {
		clearstatcache(false, $cache_file_path);
		clearstatcache(false, $ini_path);
		return file_exists($cache_file_path) && filemtime($cache_file_path) < filemtime($ini_path) ? include $cache_file_path : null;
	}
675722
public static function getApplicationName():?string
    {
        if (self::isCliApp()) {
            return self::$APPLICATION_NAME;
        }

        return MSession::get(MCoreApplication::APPLICATION_NAME);
    }
482629
def load_from_ini(self):
        
        try:
            if PY2:
                # Python 2
                fname = self.filename()
                if osp.isfile(fname):
                    try:
                        with codecs.open(fname, encoding='utf-8') as configfile:
                            self.readfp(configfile)
                    except IOError:
                        print("Failed reading file", fname)  # spyder: test-skip
            else:
                # Python 3
                self.read(self.filename(), encoding='utf-8')
        except cp.MissingSectionHeaderError:
            print("Warning: File contains no section headers.")
284718
def get_calling_file(file_path=None, result='name'):
    
    # Get full path of calling python script
    if file_path is None:
        path = inspect.stack()[1][1]
    else:
        path = file_path

    name = path.split('/')[-1].split('.')[0]
    if result == 'name':
        return name
    elif result == 'path':
        return path
    else:
        return path, name
932321
def get_config_file():
    # type: () -> AnyStr
    """"""
    parser = argparse.ArgumentParser(description="Read configuration file.")
    parser.add_argument('-ini', help="Full path of configuration file")
    args = parser.parse_args()
    ini_file = args.ini
    if not FileClass.is_file_exists(ini_file):
        print("Usage: -ini <full path to the configuration file.>")
        exit(-1)
    return ini_file
1265210
def get_app_guid(self, app_name):
        
        summary = self.space.get_space_summary()
        for app in summary['apps']:
            if app['name'] == app_name:
                return app['guid']
100237
def pools_config_content_from_file(config_path)
      ini_file = IniFile.load(config_path)

      ret_val = []
      ini_file.each_section do |section|
        ret_val << [section, ini_file[section]]
      end
      ret_val
    end
64511
def get_app_dir(app):
    
    path = __app_dirs__.get(app)
    if path is not None:
        return path
    else:
        p = app.split('.')
        try:
            path = pkg.resource_filename(p[0], '')
        except ImportError as e:
            log.error("Can't import app %s" % app)
            log.exception(e)
            path = ''
        if len(p) > 1:
            path = os.path.join(path, *p[1:])
        
        __app_dirs__[app] = path
        return path
781193
def load_application_info(path):
        
        with open(path + 'info.json', 'r') as infoFile:
            info = json.loads(infoFile.read())
        return info
515533
def get_project_name():
    
    setup_py_content = helpers.get_file_content('setup.py')
    ret = helpers.value_of_named_argument_in_function(
        'name', 'setup', setup_py_content, resolve_varname=True
    )
    if ret and ret[0] == ret[-1] in ('"', "'"):
        ret = ret[1:-1]
    return ret
365377
def _get_file_name(file_path):
    

    file_name = basename(file_path)

    utf8_file_name = bytearray(file_name, "utf8")
    utf8_file_name.append(0)

    return utf8_file_name
623944
def which(name):
    

    # we were given a filename, return it if it's executable
    if os.path.dirname(name) != '':
        if not os.path.isdir(name) and os.access(name, os.X_OK):
            return name
        else:
            return None

    # fetch PATH env var and split
    path_val = os.environ.get('PATH', None) or os.defpath

    # return the first match in the paths
    for path in path_val.split(os.pathsep):
        filename = os.path.join(path, name)

        if os.access(filename, os.X_OK):
            return filename

    return None
723776
def from_ini(cls, ic, folder='.', ini_file='star.ini'):
        
        if not os.path.isabs(ini_file):
            ini_file = os.path.join(folder,ini_file)

        config = ConfigObj(ini_file)
        kwargs = {}
        for kw in config.keys():
            try:
                kwargs[kw] = float(config[kw])
            except:
                kwargs[kw] = (float(config[kw][0]), float(config[kw][1]))

        return cls(ic, **kwargs)
934685
def inis2dict(ini_paths: Union[str, Sequence[str]]) -> dict:
    

    var_dflt = r'\${(.*?):-(.*?)}'
    def _interpolate(content):
        rv = expandvars(content)
        while True:
            match = re.search(var_dflt, rv)
            if match is None:
                break
            bash_var = '${{{}}}'.format(match.group(1))
            value = expandvars(bash_var)
            rv = re.sub(var_dflt, match.group(2) if value == bash_var else value, rv, count=1)

        return rv

    parser = ConfigParser()

    for ini in [ini_paths] if isinstance(ini_paths, str) else ini_paths:
        if not isfile(ini):
            raise FileNotFoundError('No such file: {}'.format(ini))
        with open(ini, 'r') as ini_fh:
            ini_text = _interpolate(ini_fh.read())
            parser.read_string(ini_text)

    return {s: dict(parser[s].items()) for s in parser.sections()}
496422
def is_ini_file(filename, show_warnings = False):
    
    try:
        config_dict = load_config(filename, file_type = "ini")
        if config_dict == {}:
            is_ini = False
        else:
            is_ini = True
    except:
        is_ini = False
    return(is_ini)