# 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/orbs.py
# class OrbModifier(str):
# 	"""Orb modifier type.
# 	
# 	Used to adjust orbs depending on the aspected planet.
# 	
# 	Either a float value, to add or substrat degrees (absolute),
# 	or a percentage value, to adjust the default orb (relative).
# 	
# 	"""
# 
# 	__slots__ = tuple()
# 	
# 	def __new__(cls, modifier):
# 		"""New orb modifier.
# 		
# 		:type modifier: str or numeric
# 		"""
# 		modifier = str(modifier)
# 		if _regexp_orbmod.search(modifier) == None:
# 			raise ValueError('Invalid orb modifier %s.' % modifier)
# 		return str.__new__(cls, modifier)
# 	
# 	def get_absolute(self, orb):
# 		"""Get orb absolute value, compared to base orb.
# 		
# 		:type orb: numeric
# 		:rtype: Decimal
# 		"""
# 		if not self.endswith('%'):
# 			return Decimal(self)
# 		else:
# 			return (orb/Decimal('100')) * Decimal(self[:-1])
# 	
# 	def __repr__(self):
# 		return "OrbModifier('%s')" % self


import swisseph as swe
import oroboros.core.parts
	import doctest
from oroboros.core import db
from oroboros.core.orbs import OrbModifier
		"""Select a planet by num or by name.
		
		:type planet: str or int
		:raise TypeError: invalid planet
		"""
		if isinstance(planet, int):
			return self._select_by_num(planet)
		elif isinstance(planet, basestring): # str in py3
			return self._select_by_name(planet)
		raise TypeError('Invalid planet %s.' % planet)
	
	def _select_by_idx(self, idx):
		"""Select a planet definition in database (by idx).
		
		:type idx: int
		:raise ValueError: not found
		"""
		sql = "select * from Planets where _idx = ?;"
		res = db.execute(sql, (idx,)).fetchall()
		if len(res) == 0:
			raise ValueError('Invalid planet idx: %s.' % idx)
		self.set(*res[0])
	
	def _select_by_name(self, planet):
		"""Select a planet definition in database (by name).
		
		:type planet: str
		:raise ValueError: not found
		"""
		sql = "select * from Planets where name = ?;"

# 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/orbs.py
# class OrbModifier(str):
# 	"""Orb modifier type.
# 	
# 	Used to adjust orbs depending on the aspected planet.
# 	
# 	Either a float value, to add or substrat degrees (absolute),
# 	or a percentage value, to adjust the default orb (relative).
# 	
# 	"""
# 
# 	__slots__ = tuple()
# 	
# 	def __new__(cls, modifier):
# 		"""New orb modifier.
# 		
# 		:type modifier: str or numeric
# 		"""
# 		modifier = str(modifier)
# 		if _regexp_orbmod.search(modifier) == None:
# 			raise ValueError('Invalid orb modifier %s.' % modifier)
# 		return str.__new__(cls, modifier)
# 	
# 	def get_absolute(self, orb):
# 		"""Get orb absolute value, compared to base orb.
# 		
# 		:type orb: numeric
# 		:rtype: Decimal
# 		"""
# 		if not self.endswith('%'):
# 			return Decimal(self)
# 		else:
# 			return (orb/Decimal('100')) * Decimal(self[:-1])
# 	
# 	def __repr__(self):
# 		return "OrbModifier('%s')" % self


# Path: oroboros/core/planets.py
import swisseph as swe
import oroboros.core.parts
	import doctest
from oroboros.core import db
from oroboros.core.orbs import OrbModifier

		"""Select a planet by num or by name.
		
		:type planet: str or int
		:raise TypeError: invalid planet
		"""
		if isinstance(planet, int):
			return self._select_by_num(planet)
		elif isinstance(planet, basestring): # str in py3
			return self._select_by_name(planet)
		raise TypeError('Invalid planet %s.' % planet)
	
	def _select_by_idx(self, idx):
		"""Select a planet definition in database (by idx).
		
		:type idx: int
		:raise ValueError: not found
		"""
		sql = "select * from Planets where _idx = ?;"
		res = db.execute(sql, (idx,)).fetchall()
		if len(res) == 0:
			raise ValueError('Invalid planet idx: %s.' % idx)
		self.set(*res[0])
	
	def _select_by_name(self, planet):
		"""Select a planet definition in database (by name).
		
		:type planet: str
		:raise ValueError: not found
		"""
		sql = "select * from Planets where name = ?;"

		res = db.execute(sql, (planet,)).fetchall()