예제 #1
0
 def _parse_v1_content(self, extensions):
     content = []
     ents = extensions.find("2.*.*.1")
     for ent in ents:
         oid = ent[0].rtrim(1)
         content_ext = extensions.branch(oid)
         content.append(
             Content(
                 content_type=extensions.get(oid),
                 name=content_ext.get("1"),
                 label=content_ext.get("2"),
                 vendor=content_ext.get("5"),
                 url=content_ext.get("6"),
                 gpg=content_ext.get("7"),
                 enabled=content_ext.get("8"),
                 metadata_expire=content_ext.get("9"),
                 required_tags=parse_tags(content_ext.get("10")),
             )
         )
     return content
예제 #2
0
 def _parse_v1_products(self, extensions):
     """
     Returns an ordered list of all the product data in the
     certificate.
     """
     products = []
     for prod_namespace in extensions.find("1.*.1"):
         oid = prod_namespace[0]
         root = oid.rtrim(1)
         product_id = oid[1]
         ext = extensions.branch(root)
         products.append(
             Product(
                 id=product_id,
                 name=ext.get("1"),
                 version=ext.get("2"),
                 architectures=ext.get("3"),
                 provided_tags=parse_tags(ext.get("4")),
             )
         )
     return products
예제 #3
0
    def __init__(self, id=None, name=None, version=None, architectures=None, provided_tags=None):

        if name is None:
            raise CertificateException("Product missing name")
        if id is None:
            raise CertificateException("Product missing ID")

        self.id = id
        self.name = name
        self.version = version

        self.architectures = architectures
        # If this is sent in as a string split it, as the field
        # can technically be multi-valued:
        if isinstance(self.architectures, str):
            self.architectures = parse_tags(self.architectures)
        if self.architectures is None:
            self.architectures = []

        self.provided_tags = provided_tags
        if self.provided_tags is None:
            self.provided_tags = []