def mangle_paths(conf): if is_processed('project_paths', conf): return conf else: public_site_output = { 'manual': os.path.join(conf.paths.public, get_branch()), 'meta-driver': os.path.join(conf.paths.public, get_branch()), 'ecosystem': conf.paths.public, 'about': conf.paths.public, 'mms': conf.paths.public, 'training': conf.paths.public, } try: conf.paths.public_site_output = public_site_output[conf.project.name] except KeyError: conf.paths.public_site_output = conf.paths.public if conf.project.name == 'mms': conf.paths.mms = AttributeDict({ 'hosted': os.path.join(conf.paths.public, 'hosted', get_branch()), 'saas': os.path.join(conf.paths.public, 'saas') }) if conf.git.branches.current not in conf.git.branches.published: conf.paths.mms.saas = '-'.join([conf.paths.mms.saas, conf.git.branches.current]) elif conf.project.name == 'training': conf.paths.training = AttributeDict({ 'instructor': os.path.join(conf.paths.public, 'instructor'), 'student': os.path.join(conf.paths.public, 'student') }) conf.system.processed.project_paths = True return conf
def render_versions(conf=None): if is_processed('versions', conf): return conf else: conf = lazy_conf(conf) version_config_file = os.path.join(conf.paths.builddata, 'published_branches.yaml') if conf.git.branches.current == 'master' and not os.path.exists( version_config_file): return conf try: vconf_data = get_file_from_branch(version_config_file, 'master') except CommandError: setup_config_remote('master', conf) vconf_data = get_file_from_branch(version_config_file, 'master') except CommandError: return conf vconf = AttributeDict(yaml.load(vconf_data)) conf.version.update(vconf.version) conf.git.branches.update(vconf.git.branches) conf.system.processed.versions = True return conf
def mangle_paths(conf): if is_processed('project_paths', conf): return conf else: public_site_output = { 'manual': os.path.join(conf.paths.public, get_branch()), 'meta-driver': os.path.join(conf.paths.public, get_branch()), 'ecosystem': conf.paths.public, 'about': conf.paths.public, 'mms': conf.paths.public, } try: conf.paths.public_site_output = public_site_output[conf.project.name] except KeyError: conf.paths.public_site_output = conf.paths.public if conf.project.name == 'mms': conf.paths.mms = AttributeDict({ 'hosted': os.path.join(conf.paths.public, 'hosted', get_branch()), 'saas': os.path.join(conf.paths.public, 'saas') }) conf.system.processed.project_paths = True return conf
def __init__(self, doc): self.doc = doc self._directive = None self.name = doc['name'] self.program = doc['program'] for k in optional_source_fields: if k in doc: setattr(self, k, doc[k]) else: setattr(self, k, None) if 'inherit' in doc: self.inherited = True self.source = AttributeDict(doc['inherit']) else: self.inherited = False self.source = AttributeDict() if 'args' in doc: if doc['args'] is None or doc['args'] == '': pass else: self.arguments = doc['args'] if 'aliases' in doc: if doc['aliases'] is None or doc['aliases'] == '': pass else: if isinstance(doc['aliases'], list): self.aliases = doc['aliases'] else: self.aliases = [doc['aliases']] self.replacement = dict() if 'replacement' in doc: if isinstance(doc['replacement'], dict): self.replacement = doc['replacement'] # add auto-populated replacements here self.add_replacements() logmsg = 'created option representation for the {0} option for {1}' logger.debug(logmsg.format(self.name, self.program))
def __init__(self, doc): self.doc = doc self.name = doc['name'] self.program = doc['program'] self._directive = 'describe' for k in optional_source_fields: if k in doc: setattr(self, k, doc[k]) else: setattr(self, k, None) if 'inherit' in doc: self.inherited = True self.source = AttributeDict(doc['inherit']) else: self.inherited = False self.source = AttributeDict() if 'args' in doc: if doc['args'] is None or doc['args'] == '': pass else: self.arguments = doc['args'] if 'aliases' in doc: if doc['aliases'] is None or doc['aliases'] == '': pass else: if isinstance(doc['aliases'], list): self.aliases = doc['aliases'] else: self.aliases = [doc['aliases']] self.replacement = dict() if 'replacement' in doc: if isinstance(doc['replacement'], dict): self.replacement = doc['replacement'] # add auto-populated replacements here self.add_replacements()
def render_versions(conf=None): if is_processed('versions', conf): return conf else: conf = lazy_conf(conf) if 'branches' not in conf.git: conf.git.branches = AttributeDict() version_config_file = os.path.join(conf.paths.builddata, 'published_branches.yaml') try: vconf_data = get_file_from_branch(version_config_file, 'master') except CommandError: if get_branch() == 'master': return conf remotes = command('git remote', capture=True).out.split('\n') if 'origin' in remotes: return conf if 'config-upstream' not in remotes: command('git remote add config-upstream git://github.com/{0}.git'.format(conf.git.remote.upstream)) command('git fetch config-upstream') if 'master' not in command('git branch', capture=True).out.split('\n'): command('git branch master config-upstream/master') vconf_data = get_file_from_branch(version_config_file, 'master') except CommandError: return conf vconf = AttributeDict(yaml.load(vconf_data)) conf.version.update(vconf.version) conf.git.branches.update(vconf.git.branches) conf.system.processed.versions = True return conf
def schema_migration_0(conf): if 'paths' not in conf: conf.paths = AttributeDict(conf.build.paths) del conf.build['paths'] if 'system' not in conf: conf.system = AttributeDict() conf.system.make = AttributeDict() conf.system.make.generated = conf.build.system.files conf.system.make.static = conf.build.system.static del conf.build.system['files'] del conf.build.system['static'] conf.system.update(conf.build.system) del conf.build['system'] if 'build' in conf: del conf['build'] return conf
def render_git_info(conf): if is_processed('git_info', conf): return conf else: if 'branches' not in conf.git: conf.git.branches = AttributeDict() conf.git.branches.current = get_branch() conf.git.commit = get_commit() conf.system.processed.git_info = True return conf
def get_conf(): project_root_dir, conf_file, conf, cached = discover_config_file() if cached is True: return conf conf = schema_migration_0(conf) conf_file = crawl_up_tree(conf_file, 2) conf.paths.projectroot = os.path.abspath(os.path.join(os.path.dirname(conf_file), '..')) conf.system.conf_file = conf_file if os.path.exists('/etc/arch-release'): conf.system.python = 'python2' else: conf.system.python = 'python' conf.system.processed = AttributeDict() conf.system.processed.paths = False conf.system.processed.edition = False conf.system.processed.project_paths = False conf.system.processed.project_conf = False conf.system.processed.versions = False conf = mangle_configuration(conf) conf = render_versions(conf) conf.git.branches.current = get_branch() conf.git.commit = get_commit() conf.project.basepath = get_manual_path(conf) conf = render_paths(conf) conf = mangle_paths(conf) conf.system.dependency_cache = os.path.join(conf.paths.projectroot, conf.paths.branch_output, 'dependencies.json') conf_cache_dir = os.path.join(conf.paths.projectroot, conf.paths.branch_output) conf_cache = os.path.join(conf_cache_dir, 'conf-cache.json') if not os.path.exists(conf_cache_dir): os.makedirs(conf_cache_dir) with open(conf_cache, 'w') as f: json.dump(conf, f) return conf
def get_conf(): project_root_dir, conf_file, conf = discover_config_file() conf = schema_migration_0(conf) conf_file = crawl_up_tree(conf_file, 2) conf.paths.projectroot = os.path.abspath( os.path.join(os.path.dirname(conf_file), '..')) conf.system.conf_file = conf_file if os.path.exists('/etc/arch-release'): conf.system.python = 'python2' else: conf.system.python = 'python' conf.system.processed = AttributeDict() conf.system.processed.paths = False conf.system.processed.bootstrap = False conf.system.processed.edition = False conf.system.processed.project_paths = False conf.system.processed.project_conf = False conf.system.processed.versions = False conf.system.processed.assets = False conf.system.processed.language = False conf.system.processed.git_info = False conf.system.processed.cached = False conf_artifact_project = os.path.realpath( os.path.join(conf.paths.buildsystem, 'config')).split(os.path.sep)[-2] if not conf.paths.projectroot.endswith(conf_artifact_project): return safe_bootstrap(conf) # order matters here: conf = mangle_configuration(conf) conf = render_git_info(conf) conf = render_versions(conf) conf = render_assets(conf) conf = render_paths(conf) conf = mangle_paths(conf) conf = render_cache(conf) conf = render_deploy_info(conf) return conf
def mangle_configuration(conf): if is_processed('project', conf) is True: return conf else: if 'branched' not in conf.system: if conf.project.name in ['manual', 'mms', 'meta-driver']: conf.system.branched = True else: conf.system.branched = False if conf.project.name == 'primer': conf.git.branches = AttributeDict() conf.git.branches.published = ['master'] conf.git.branches.manual = None conf.system.processed.versions = True conf.version.published = ['master'] conf.version.stable = None conf.version.upcoming = None conf.paths.manual_source = os.path.abspath(os.path.join(conf.paths.projectroot, '..', 'source')) conf.system.processed.project_conf = True return conf
def compute_sphinx_config(builder, sconf, conf): # vestigial. most of the logic of this function was moved into # utils.config.render_sphinx_config computed_config = deepcopy(sconf) if 'editions' in sconf: if 'builder' not in computed_config: sp_builder = builder.split('-')[0] logger.debug('set builder for {0} to {1}'.format( builder, sp_builder)) computed_config[builder]['builder'] = sp_builder logger.debug(computed_config[builder]) if 'edition' not in computed_config[builder]: logger.critical( '[sphinx] [error]: builds with editions must specify an edition.' ) else: computed_config['edition'] = None return AttributeDict(computed_config[builder])