def __init__(self, spec, variants): self.unknown_variants = variants variant_str = 'variant' if len(variants) == 1 else 'variants' msg = ('trying to set {0} "{1}" in package "{2}", but the package' ' has no such {0} [happened during concretization of {3}]') msg = msg.format(variant_str, comma_or(variants), spec.name, spec.root) super(UnknownVariantError, self).__init__(msg)
def __init__(self, name, *rev_types, **kwargs): super(VCSFetchStrategy, self).__init__() self.name = name # Set a URL based on the type of fetch strategy. self.url = kwargs.get(name, None) if not self.url: raise ValueError("%s requires %s argument." % (self.__class__, name)) # Ensure that there's only one of the rev_types if sum(k in kwargs for k in rev_types) > 1: raise ValueError("Supply only one of %s to fetch with %s" % (comma_or(rev_types), name)) # Set attributes for each rev type. for rt in rev_types: setattr(self, rt, kwargs.get(rt, None))
def __init__(self, pkg, variants): self.unknown_variants = variants super(UnknownVariantError, self).__init__('Package {0} has no variant {1}!'.format( pkg, comma_or(variants)))