# Path: oroboros/core/db.py
# class Object(object):
# 	def _get_idx(self):
# 	def _set_idx(self, idx):
# def _connect(dsn=_dsn):
# def _cursor(conn):
# def connect(dsn=_dsn):
# def execute(sql, var=None):
# def close():
# def autoconnect(dsn=_dsn):
# def _execute_file(path):
# def install(path=_dsn):
# def _check_version():
# def _create_functions(cnx):
# 	def regexp_search(pattern, string):
# def _test():
# 
# Path: oroboros/core/xmlutils.py
# def _serialize(obj):
# 	def _get_elem(self):
# 	def _set_elem(self, elem):
# 	def _get_tag(self):
# 	def _set_tag(self, tag):
# 	def _get_attributes(self):
# 	def _set_attributes(self, attrdict):
# 	def _get_text(self):
# 	def _set_text(self, text):
# 	def _get_tail(self):
# 	def _set_tail(self, tail):
# 	def __init__(self, tag=None, attributes={}, text='', tail='',
# 		_etree_elem=None):
# 	def has_attr(self, attribute):
# 	def get_attr(self, attribute):
# 	def set_attr(self, attribute, value):
# 	def append(self, elem=None, attributes={}, text='', tail='',
# 		_etree_elem=None):
# 	def insert(self, elem, attributes={}, text='', tail='', idx=0,
# 		_etree_elem=None):
# 	def prepend(self, elem, attributes={}, text='', tail='', _etree_elem=None):
# 	def get_child(self, idx=0, tag=None):
# 	def get_children(self, tag=None):
# 	def get_child_text(self, idx=0, tag=None):
# 	def get_child_attr(self, attr, idx=0, tag=None):
# 	def remove_child(self, idx=0, tag=None):
# 	def remove_children(self, tag):
# 	def clear(self):
# 	def __len__(self):
# 	def write(self, path, encoding='UTF-8'):
# 	def dump(self):
# 	def __str__(self, encoding='UTF-8'):
# 	def __iter__(self):
# 	def get_iterator(self, tag):
# 	def __contains__(self, tag):
# def parse(path):
# def comment(text):
# def _test():
# class Element(object):


from oroboros.core import db
from oroboros.core import xmlutils
	import doctest
			self._insert()
		else:
			self._update()
	
	def _insert(self):
		"""Insert aspects filter in database.
		
		:raise ValueError: duplicate
		"""
		sql1 = "insert into AspectsFilters (name, comment) values (?, ?);"
		sql2 = "select _idx from AspectsFilters where name = ?;"
		try:
			db.execute(sql1, (self._name, self._comment))
		except: # sqlite3.IntegrityError
			raise ValueError('Duplicate filter %s.' % self._name)
		self._idx = db.execute(sql2,(self._name,)).fetchone()[0]
		self._save_dict()
	
	def _update(self):
		"""Update aspects filter in database."""
		sql = "update AspectsFilters set name = ?, comment = ? where _idx = ?;"
		db.execute(sql, (self._name, self._comment, self._idx_))
		self._save_dict()
	
	def _save_dict(self):
		"""Save aspects filter dict in database (with filter idx)."""
		self._delete_dict()
		sql = """insert into _AspectsFilters select ?, _idx, ? from Aspects
			where name = ?;"""
		for asp, val in self._dict_.items():

# Path: oroboros/core/db.py
# class Object(object):
# 	def _get_idx(self):
# 	def _set_idx(self, idx):
# def _connect(dsn=_dsn):
# def _cursor(conn):
# def connect(dsn=_dsn):
# def execute(sql, var=None):
# def close():
# def autoconnect(dsn=_dsn):
# def _execute_file(path):
# def install(path=_dsn):
# def _check_version():
# def _create_functions(cnx):
# 	def regexp_search(pattern, string):
# def _test():
# 
# Path: oroboros/core/xmlutils.py
# def _serialize(obj):
# 	def _get_elem(self):
# 	def _set_elem(self, elem):
# 	def _get_tag(self):
# 	def _set_tag(self, tag):
# 	def _get_attributes(self):
# 	def _set_attributes(self, attrdict):
# 	def _get_text(self):
# 	def _set_text(self, text):
# 	def _get_tail(self):
# 	def _set_tail(self, tail):
# 	def __init__(self, tag=None, attributes={}, text='', tail='',
# 		_etree_elem=None):
# 	def has_attr(self, attribute):
# 	def get_attr(self, attribute):
# 	def set_attr(self, attribute, value):
# 	def append(self, elem=None, attributes={}, text='', tail='',
# 		_etree_elem=None):
# 	def insert(self, elem, attributes={}, text='', tail='', idx=0,
# 		_etree_elem=None):
# 	def prepend(self, elem, attributes={}, text='', tail='', _etree_elem=None):
# 	def get_child(self, idx=0, tag=None):
# 	def get_children(self, tag=None):
# 	def get_child_text(self, idx=0, tag=None):
# 	def get_child_attr(self, attr, idx=0, tag=None):
# 	def remove_child(self, idx=0, tag=None):
# 	def remove_children(self, tag):
# 	def clear(self):
# 	def __len__(self):
# 	def write(self, path, encoding='UTF-8'):
# 	def dump(self):
# 	def __str__(self, encoding='UTF-8'):
# 	def __iter__(self):
# 	def get_iterator(self, tag):
# 	def __contains__(self, tag):
# def parse(path):
# def comment(text):
# def _test():
# class Element(object):


# Path: oroboros/core/aspectsfilters.py
from oroboros.core import db
from oroboros.core import xmlutils
	import doctest

			self._insert()
		else:
			self._update()
	
	def _insert(self):
		"""Insert aspects filter in database.
		
		:raise ValueError: duplicate
		"""
		sql1 = "insert into AspectsFilters (name, comment) values (?, ?);"
		sql2 = "select _idx from AspectsFilters where name = ?;"
		try:
			db.execute(sql1, (self._name, self._comment))
		except: # sqlite3.IntegrityError
			raise ValueError('Duplicate filter %s.' % self._name)
		self._idx = db.execute(sql2,(self._name,)).fetchone()[0]
		self._save_dict()
	
	def _update(self):
		"""Update aspects filter in database."""
		sql = "update AspectsFilters set name = ?, comment = ? where _idx = ?;"
		db.execute(sql, (self._name, self._comment, self._idx_))
		self._save_dict()
	
	def _save_dict(self):
		"""Save aspects filter dict in database (with filter idx)."""
		self._delete_dict()
		sql = """insert into _AspectsFilters select ?, _idx, ? from Aspects
			where name = ?;"""
		for asp, val in self._dict_.items():

			db.execute(sql, (self._idx_, int(val), asp))