Exemplo n.º 1
0
    def _load(file):
        try:
            f = open(file)
            soup = BeautifulSoup(f.read(), "lxml")

            for rule in soup.find_all("rule"):
                r = Rule(rule.attrs)
                if r in Rules._rules:
                    i = Rules._rules.index(r)
                    Rules._rules[i].update(r)
                else:
                    r.setdefault('action', Rules._DEFAULT_ACTION)
                    Rules._rules.append(r)

            f.close()

        except IOError:
            raise PathNotFound('DATA_DIR')
Exemplo n.º 2
0
	def _load(file):
		try:
			f = open(file)
			soup = BeautifulSoup(f.read(), "lxml")

			for child in soup.applications.children:
				if not isinstance(child, element.Tag):
					continue

				if child.name == "app":
					Applications._append_application(child.attrs)

				if child.name == "group":
					for app in child.findChildren():
						Applications._append_application(app.attrs, child.attrs)
			f.close()

		except IOError:
			raise PathNotFound('DATA_DIR')