def __init__(self):
        config_file = os.environ.get(self.VIRTUALENV_CONFIG_FILE_ENV_VAR, None)
        self.is_env_var = config_file is not None
        config_file = (
            Path(config_file) if config_file is not None else
            Path(user_config_dir(appname="virtualenv", appauthor="pypa")) /
            "virtualenv.ini")
        self.config_file = config_file
        self._cache = {}

        exception = None
        self.has_config_file = None
        try:
            self.has_config_file = self.config_file.exists()
        except OSError as exc:
            exception = exc
        else:
            if self.has_config_file:
                self.config_file = self.config_file.resolve()
                self.config_parser = ConfigParser.ConfigParser()
                try:
                    self._load()
                    self.has_virtualenv_section = self.config_parser.has_section(
                        self.section)
                except Exception as exc:
                    exception = exc
        if exception is not None:
            logging.error("failed to read config file %s because %r",
                          config_file, exception)
Exemple #2
0
 def _console_scripts(self):
     if self._extracted is False:
         return None  # pragma: no cover
     if self._console_entry_points is None:
         self._console_entry_points = {}
         entry_points = self._dist_info / "entry_points.txt"
         if entry_points.exists():
             parser = ConfigParser.ConfigParser()
             with entry_points.open() as file_handler:
                 parser.read_file(file_handler)
             if "console_scripts" in parser.sections():
                 for name, value in parser.items("console_scripts"):
                     match = re.match(r"(.*?)-?\d\.?\d*", name)
                     if match:
                         name = match.groups(1)[0]
                     self._console_entry_points[name] = value
     return self._console_entry_points
 def __init__(self):
     config_file = os.environ.get(self.VIRTUALENV_CONFIG_FILE_ENV_VAR, None)
     self.is_env_var = config_file is not None
     self.config_file = Path(
         config_file) if config_file is not None else DEFAULT_CONFIG_FILE
     self._cache = {}
     self.has_config_file = self.config_file.exists()
     if self.has_config_file:
         self.config_file = self.config_file.resolve()
         self.config_parser = ConfigParser.ConfigParser()
         try:
             self._load()
             self.has_virtualenv_section = self.config_parser.has_section(
                 self.section)
         except Exception as exception:
             logging.error("failed to read config file %s because %r",
                           config_file, exception)
             self.has_config_file = None