def get_package_section(cfg, package, version): '''Return a dictionary of the first package section of <cfg> with given <package> name and a version consistent with <version>. ''' for section in package_sections(cfg.sections(), package): constraint = section_constraint(section) if constraint and not version_consistent(version, constraint): continue return dict(cfg.items(section, raw=True)) raise ValueError, 'No consistent package section for %s/%s found' % \ (package, version)
def get_shim(name, constraint): for s in shim_list: if s.name != name: continue if not constraint: return s if version_consistent(s.version, constraint): return s else: log.warning('Package "%s/%s" inconsistent with constraint "%s"' % \ (s.name, s.version, constraint)) continue raise ValueError, 'No shim satisfying "%s/%s" in setup' % \ (name, constraint or "(any)")
def shims_in(shimlist, name, constraint = None): ''' Return list of all shim objects in <shimlist> with the given name. If a constraint is given then a shim must satisfy it to be returned. ''' ret = [] for s in shimlist: if name != s.name: continue if not constraint or version_consistent(s.version, constraint): ret.append(s) continue continue return ret