def test_open(self): """Test openning a configuration file """ config = Configuration.read( os.path.join(get_test_file_directory(), "configuration.cfg")) self.assertNotEqual(config, None) self.failUnless(isinstance(config, Configuration)) self.assertRaises(FileError, Configuration.read, "not_existing")
def __call__(self, distribution, path, interpretor, trust=-99): setup_cfg = os.path.join(path, 'monteur.cfg') if os.path.isfile(setup_cfg): configuration = Configuration.read(setup_cfg) if 'egginfo' in configuration.sections: return SetupLoader(configuration, distribution, interpretor) logger.debug( u"Missing monteur package configuration in %s", setup_cfg) return None
def get_previous_cfg(self, *ignore): """Return a previous configuration used to setup this environment. """ directory = self.get_previous_cfg_directory() if directory is not None: filename = os.path.join(directory, PREVIOUS_CONFIG_FILE) if os.path.isfile(filename): logger.info(u'Loading previous configuration') return Configuration.read(filename) return Configuration()
def get_default_cfg(self): """Return the default configuration. """ directory = self.get_default_cfg_directory() filename = os.path.join(directory, DEFAULT_CONFIG_FILE) if not os.path.isfile(filename): try: shutil.copy( os.path.join(os.path.dirname(__file__), 'default.cfg'), filename) except IOError: sys.stderr.write('Cannot install default configuration.') sys.exit(-1) logger.info(u'Reading default configuration.') return Configuration.read(filename)
def load(self, distribution, interpretor): distribution.package_path = self.path # Read extracted configuration config = Configuration.read_lines(self.source.splitlines, self.path) setuptool_config = config['setuptools'] distribution.version = Version.parse( setuptool_config['version'].as_text()) # Look for requirements if 'install_requires' in setuptool_config: distribution.requirements = Requirements.parse( setuptool_config['install_requires'].as_list()) if 'extras_require' in setuptool_config: extra_config = config[setuptool_config['extras_require'].as_text()] for extra, extra_requirements in extra_config.items(): distribution.extras[extra] = Requirements.parse( extra_requirements.as_list()) # Look for source directory if 'package_dir' in setuptool_config: package_config = config[ setuptool_config['package_dir'].as_text()] if '_' in package_config: prefix = package_config['_'].as_text() distribution.path = os.path.join(self.path, prefix) if 'description' in setuptool_config: distribution.description = setuptool_config['description'].as_text() if 'license' in setuptool_config: distribution.license = setuptool_config['license'].as_text() if 'author' in setuptool_config: distribution.author = setuptool_config['author'].as_text() if 'autor_email' in setuptool_config: distribution.author_email = \ setuptool_config['author_email'].as_text() if 'ext_modules' in setuptool_config: libraries = self.extensions(prefix, setuptool_config) create_autotools(distribution, prefix, libraries) distribution.extensions = libraries return distribution
def setUp(self): self.config = Configuration.read( os.path.join(get_test_file_directory(), "configuration.cfg")) self.section = self.config['section']