Exemplo n.º 1
0
 def parse(clazz, text, default_system_mask=None):
     if check.is_string_seq(text):
         text = ' '.join(text)
     check.check_string(text)
     reqs = clazz([
         req for req in requirement_parser.parse(
             text, default_system_mask=default_system_mask)
     ])
     reqs.remove_dups()
     return reqs
Exemplo n.º 2
0
 def resolve(clazz, what):
   if check.is_string(what):
     return clazz([ package_descriptor.parse(pkg_descs) ])
   elif check.is_string_seq(what):
     return clazz([ package_descriptor.parse(p) for p in what ])
   elif check.is_package_descriptor(what):
     return clazz([ what ])
   elif check.is_package_descriptor_seq(what):
     return what
   else:
     raise TypeError('Cannot resolve to package descriptor list: %s - %s' % (str(what), type(what)))
Exemplo n.º 3
0
 def normalize(clazz, arch):
     'Normalize arch into a tuple.'
     if check.is_string(arch):
         return tuple(sorted(clazz.split(arch)))
     elif check.is_string_seq(arch):
         result = []
         for a in arch:
             result.extend(list(clazz.split(a)))
         return tuple(sorted(result))
     else:
         raise TypeError('Invalid type for arch: %s - %s' %
                         (str(arch), type(arch)))
Exemplo n.º 4
0
    def __new__(clazz, mask, value, origin=None):
        if not check.is_value_base(value):
            if check.is_bool(value):
                value = value_bool(origin=origin, value=value)
            elif check.is_int(value):
                value = value_int(origin=origin, value=value)
            elif check.is_string(value):
                value = value_string(origin=origin, value=value)
            elif check.is_string_list(value) or check.is_string_seq(value):
                value = value_string_list(origin=origin, values=value)
            elif check.is_key_value_list(value):
                value = value_key_values(origin=origin, values=value)

        if not check.is_value_base(value):
            raise TypeError('value should be subclass of value_base: %s - %s' %
                            (str(value), type(value)))

        if origin:
            check.check_value_origin(origin)
        return clazz.__bases__[0].__new__(clazz, mask, value)
Exemplo n.º 5
0
 def test_is_string_seq(self):
   self.assertTrue( C.is_string_seq([ 'foo' ]) )
   self.assertFalse( C.is_string_seq('foo') )
Exemplo n.º 6
0
 def __eq__(self, other):
   if check.is_string_seq(other):
     return self.values == other
   return self.values == other.values