Example #1
0
    def __init__(self, coll):
        check_schema(coll, "collection", ["id", "author", "license", "blt-version", "classes"], ["name", "description"])

        version = coll["blt-version"]
        if version != CURRENT_VERSION:
            raise VersionError(version)

        self.id = coll["id"]

        self.name = coll.get("name", "")
        self.description = coll.get("description", "")

        self.authors = coll["author"]
        if isinstance(self.authors, str):
            self.authors = [self.authors]

        self.author_names = []
        self.author_mails = []
        for author in self.authors:
            match = parse_angled(author)
            self.author_names.append(match[0])
            self.author_mails.append(match[1])

        self.license = coll["license"]
        match = parse_angled(self.license)
        self.license_name = match[0]
        self.license_url = match[1]
Example #2
0
    def __init__(self, coll):
        check_schema(coll, "collection",
                     ["id", "author", "license", "blt-version", "classes"],
                     ["name", "description"])

        version = coll["blt-version"]
        if version != CURRENT_VERSION:
            raise VersionError(version)

        self.id = coll["id"]

        self.name = coll.get("name", "")
        self.description = coll.get("description", "")

        self.authors = coll["author"]
        if isinstance(self.authors, str):
            self.authors = [self.authors]

        self.author_names = []
        self.author_mails = []
        for author in self.authors:
            match = parse_angled(author)
            self.author_names.append(match[0])
            self.author_mails.append(match[1])

        self.license = coll["license"]
        match = parse_angled(self.license)
        self.license_name = match[0]
        self.license_url = match[1]
Example #3
0
	def __init__(self,coll):
		check_schema(coll,"collection",
			["id","author","license","blt-version","classes"],
			["name","description"]
		)

		version = coll["blt-version"]
		if version != CURRENT_VERSION:
			raise VersionError(version)

		self.id = coll["id"]

		self.name = ""
		if "name" in coll:
			self.name = coll["name"]

		self.description = ""
		if "description" in coll:
			self.description = coll["description"]

		self.authors = coll["author"]
		if isinstance(self.authors,str):
			self.authors = [self.authors]

		self.author_names = []
		self.author_mails = []
		for author in self.authors:
			match = parse_angled(author)
			self.author_names.append(match[0])
			self.author_mails.append(match[1])

		self.license = coll["license"]
		match = parse_angled(self.license)
		self.license_name = match[0]
		self.license_url = match[1]

		#parse classes
		if not isinstance(coll["classes"],list):
			raise MalformedCollectionError("No class in collection %s"% self.id)

		self.classes = []
		classids = []
		for cl in coll["classes"]:
			names = cl["id"]
			if cl["id"] in classids:
				raise NonUniqueClassIdError(cl["id"])
			classids.append(cl["id"])
			if "standard" in cl:
				names = cl["standard"]
			if isinstance(names,str):
				names = [names]
			for name in names:
				try:
					self.classes.append(BOLTSClass(cl,name))
				except ParsingError as e:
					e.set_class(name)
					raise
Example #4
0
	def test_garbage(self):
		res = common.parse_angled("Johannes Reinhardt <*****@*****.**> Garbage")
		self.assertEqual(res[0],"Johannes Reinhardt")
		self.assertEqual(res[1],"*****@*****.**")
Example #5
0
	def test_empty(self):
		res = common.parse_angled("<*****@*****.**> Garbage")
		self.assertEqual(res[0],"")
		self.assertEqual(res[1],"*****@*****.**")
Example #6
0
 def test_wellformed(self):
     res = common.parse_angled(
         "Johannes Reinhardt <*****@*****.**>")
     self.assertEqual(res[0], "Johannes Reinhardt")
     self.assertEqual(res[1], "*****@*****.**")
Example #7
0
 def test_empty(self):
     res = common.parse_angled("<*****@*****.**> Garbage")
     self.assertEqual(res[0], "")
     self.assertEqual(res[1], "*****@*****.**")