def test_confdir_snap_nonexistant(self): with tempfile.TemporaryDirectory() as dirname: self._fake_snap_env_dir(dirname) direct = helpers.get_confdir() self.assertTrue(os.path.exists(direct))
def test_confdir_default(self): with patch.object(helpers, "_get_basedirectory") as mock: mock.side_effect = ImportError() direct = helpers.get_confdir() self.assertEqual(direct, os.path.join(self._home, '.fades'))
def test_confdir_xdg_nonexistant(self): with patch("xdg.BaseDirectory") as mock: with tempfile.TemporaryDirectory() as dirname: mock.xdg_config_home = dirname direct = helpers.get_confdir() self.assertTrue(os.path.exists(direct))
def test_confdir_xdg(self): direct = helpers.get_confdir() self.assertEqual(direct, os.path.join(BaseDirectory.xdg_config_home, 'fades'))
def test_confdir_snap(self): with tempfile.TemporaryDirectory() as dirname: self._fake_snap_env_dir(dirname) direct = helpers.get_confdir() self.assertEqual(direct, os.path.join(dirname, 'config'))
# with this program. If not, see <http://www.gnu.org/licenses/>. # # For further info, check https://github.com/PyAr/fades """Parse fades options from config files.""" import logging import os from configparser import ConfigParser, NoSectionError from fades.helpers import get_confdir logger = logging.getLogger(__name__) CONFIG_FILES = ("/etc/fades/fades.ini", os.path.join(get_confdir(), 'fades.ini'), ".fades.ini") MERGEABLE_CONFIGS = ("dependency", "pip_options", "virtualenv-options") def options_from_file(args): """Get a argparse.Namespace and return it updated with options from config files. Config files will be parsed with priority equal to his order in CONFIG_FILES. """ logger.debug("updating options from config files") updated_from_file = [] for config_file in CONFIG_FILES: logger.debug("updating from: %s", config_file) parser = ConfigParser() parser.read(config_file)