Exemplo n.º 1
0
    def _save_dict(self):
        """Save orbs restrictions dict in database (with idx)."""
        self._delete_dict()
        sql = """insert into _OrbsRestrictions select ?, _idx, ? from
			Planets where name = ?;"""
        for plt, val in self.items():
            db.execute(sql, (self._idx_, val, plt))
Exemplo n.º 2
0
	def _save_dict(self):
		"""Save aspects restrictions dict in database (with filter idx)."""
		self._delete_dict()
		sql = """insert into _AspectsRestrictions select ?, _idx, ? from
			Planets where name = ?;"""
		for plt, val in self.items():
			db.execute(sql, (self._idx_, int(val), plt))
Exemplo n.º 3
0
    def _save_dict(self):
        """Save orbs filter dict in database (with filter idx)."""
        self._delete_dict()
        sql = """insert into _OrbsFilters select ?, _idx, ? from Aspects
			where name = ?;"""
        for asp, val in self.items():
            db.execute(sql, (self._idx_, float(val), asp))
Exemplo n.º 4
0
	def _save_dict(self):
		"""Save orbs restrictions dict in database (with idx)."""
		self._delete_dict()
		sql = """insert into _OrbsRestrictions select ?, _idx, ? from
			Planets where name = ?;"""
		for plt, val in self.items():
			db.execute(sql, (self._idx_, val, plt))
Exemplo n.º 5
0
	def _save_dict(self):
		"""Save planets filter dict in database (with filter idx)."""
		self._delete_dict()
		sql = """insert into _PlanetsFilters select ?, _idx, ? from Planets
			where name = ?;"""
		for plnt, val in self._dict_.items():
			db.execute(sql, (self._idx_, int(val), plnt))
Exemplo n.º 6
0
    def _save_dict(self):
        """Save aspects restrictions dict in database (with filter idx)."""
        self._delete_dict()
        sql = """insert into _AspectsRestrictions select ?, _idx, ? from
			Planets where name = ?;"""
        for plt, val in self.items():
            db.execute(sql, (self._idx_, int(val), plt))
Exemplo n.º 7
0
    def _save_dict(self):
        """Save planets filter dict in database (with filter idx)."""
        self._delete_dict()
        sql = """insert into _PlanetsFilters select ?, _idx, ? from Planets
			where name = ?;"""
        for plnt, val in self._dict_.items():
            db.execute(sql, (self._idx_, int(val), plnt))
Exemplo n.º 8
0
	def _save_dict(self):
		"""Save orbs filter dict in database (with filter idx)."""
		self._delete_dict()
		sql = """insert into _OrbsFilters select ?, _idx, ? from Aspects
			where name = ?;"""
		for asp, val in self.items():
			db.execute(sql, (self._idx_, float(val), asp))
Exemplo n.º 9
0
    def delete(self):
        """Delete aspect in database.
		
		:raise TypeError: missing index
		"""
        if self._idx_ == None:
            raise TypeError('Missing idx.')
        sql = "delete from Aspects where _idx = ?;"
        db.execute(sql, (self._idx_, ))
        self._idx_ = None
Exemplo n.º 10
0
	def delete(self):
		"""Delete planet definition in database (by idx).
		
		:raise TypeError: invalid index
		"""
		if self._idx_ == None:
			raise TypeError('Missing planet idx.')
		sql = "delete from Planets where _idx = ?;"
		db.execute(sql, (self._idx_,))
		self._idx_ = None
Exemplo n.º 11
0
    def _update(self):
        """Update orbs filter in database.
		
		:raise ValueError: duplicate
		"""
        sql = "update OrbsFilters set name = ?, comment = ? where _idx = ?;"
        try:
            db.execute(sql, (self._name, self._comment, self._idx_))
        except:
            raise ValueError('Duplicate filter %s.' % self._name)
        self._save_dict()
Exemplo n.º 12
0
	def _update(self):
		"""Update orbs filter in database.
		
		:raise ValueError: duplicate
		"""
		sql = "update OrbsFilters set name = ?, comment = ? where _idx = ?;"
		try:
			db.execute(sql, (self._name, self._comment, self._idx_))
		except:
			raise ValueError('Duplicate filter %s.' % self._name)
		self._save_dict()
Exemplo n.º 13
0
	def _update(self):
		"""Update aspects restrictions filter in database.
		
		:raise ValueError: duplicate
		"""
		sql = """update AspectsRestrictions set name = ?, comment = ?
			where _idx = ?;"""
		try:
			db.execute(sql, (self._name, self._comment, self._idx_))
		except: # integrity error
			raise ValueError('Duplicate filter %s.' % self._name)
		self._save_dict()
Exemplo n.º 14
0
    def _update(self):
        """Update aspects restrictions filter in database.
		
		:raise ValueError: duplicate
		"""
        sql = """update AspectsRestrictions set name = ?, comment = ?
			where _idx = ?;"""
        try:
            db.execute(sql, (self._name, self._comment, self._idx_))
        except:  # integrity error
            raise ValueError('Duplicate filter %s.' % self._name)
        self._save_dict()
Exemplo n.º 15
0
	def _insert(self):
		"""Insert new orbs filter in database.
		
		:raise ValueError: duplicate
		"""
		sql1 = "insert into OrbsFilters (name, comment) values (?, ?);"
		sql2 = "select _idx from OrbsFilters 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()
Exemplo n.º 16
0
    def _insert(self):
        """Insert new orbs filter in database.
		
		:raise ValueError: duplicate
		"""
        sql1 = "insert into OrbsFilters (name, comment) values (?, ?);"
        sql2 = "select _idx from OrbsFilters 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()
Exemplo n.º 17
0
	def delete(self):
		"""Delete aspects restrictions in database.
		
		:raise TypeError: invalid index
		:raise ValueError: integrity error
		"""
		if self._idx_ == None:
			raise TypeError('Missing idx.')
		sql = "delete from AspectsRestrictions where _idx = ?;"
		try:
			db.execute(sql, (self._idx_,))
		except: # integrity error
			raise ValueError('Cannot delete default filter')
		self._idx_ = None
Exemplo n.º 18
0
    def delete(self):
        """Delete aspects restrictions in database.
		
		:raise TypeError: invalid index
		:raise ValueError: integrity error
		"""
        if self._idx_ == None:
            raise TypeError('Missing idx.')
        sql = "delete from AspectsRestrictions where _idx = ?;"
        try:
            db.execute(sql, (self._idx_, ))
        except:  # integrity error
            raise ValueError('Cannot delete default filter')
        self._idx_ = None
Exemplo n.º 19
0
	def delete(self):
		"""Delete filter in database.
		
		:raise TypeError: invalid index
		:raise ValueError: integrity error
		"""
		if self._idx_ == None:
			raise TypeError('Missing idx')
		sql = "delete from Filters where _idx = ?;"
		try:
			db.execute(sql, (self._idx_,))
		except: # sqlite3 integrity error
			raise ValueError('Cannot delete default filter.')
		self._idx_ = None
Exemplo n.º 20
0
	def _insert(self):
		"""Insert orbs restrictions filter in database.
		
		Raise ValueError if duplicate.
		
		"""
		sql1 = "insert into OrbsRestrictions (name, comment) values (?, ?);"
		sql2 = "select _idx from OrbsRestrictions 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()
Exemplo n.º 21
0
    def _insert(self):
        """Insert orbs restrictions filter in database.
		
		Raise ValueError if duplicate.
		
		"""
        sql1 = "insert into OrbsRestrictions (name, comment) values (?, ?);"
        sql2 = "select _idx from OrbsRestrictions 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()
Exemplo n.º 22
0
    def delete(self):
        """Delete orbs filter in database (by idx).
		
		:raise TypeError: invalid index
		:raise ValueError: integrity error
		"""
        if self._idx_ == None:
            raise TypeError('Missing idx.')
        sql = "delete from OrbsFilters where _idx = ?;"
        try:
            db.execute(sql, (self._idx_, ))
        except:  # integrity error
            raise ValueError('Cannot delete default filter.')
        self._idx_ = None
Exemplo n.º 23
0
	def delete(self):
		"""Delete orbs restrictions in database (by idx).
		
		Raise TypeError if idx is None.
		Raise ValueError if filter is required by default filter.
		
		"""
		if self._idx_ == None:
			raise TypeError('Missing idx.')
		sql = "delete from OrbsRestrictions where _idx = ?;"
		try:
			db.execute(sql, (self._idx_,))
		except:
			raise ValueError('Cannot delete default filter.')
		self._idx_ = None
Exemplo n.º 24
0
    def _update(self):
        """Update aspect in database.
		
		:raise ValueError: duplicate
		"""
        sql = """update Aspects set name = ?, angle = ?, ranking = ?,
			bool_use = ?, default_orb = ?, color = ?, glyph = ?,
			comment = ? where _idx = ?;"""
        var = (self._name, str(self._angle),
               self._ranking, int(self._bool_use), str(self._default_orb),
               str(self._color), self._glyph, self._comment, self._idx_)
        try:
            db.execute(sql, var)
        except:  # integrity error
            raise ValueError('Duplicate aspect.')
Exemplo n.º 25
0
    def delete(self):
        """Delete orbs restrictions in database (by idx).
		
		Raise TypeError if idx is None.
		Raise ValueError if filter is required by default filter.
		
		"""
        if self._idx_ == None:
            raise TypeError('Missing idx.')
        sql = "delete from OrbsRestrictions where _idx = ?;"
        try:
            db.execute(sql, (self._idx_, ))
        except:
            raise ValueError('Cannot delete default filter.')
        self._idx_ = None
Exemplo n.º 26
0
	def _update(self):
		"""Update planet definition in database.
		
		:raise ValueError: duplicate
		"""
		sql = """update Planets set num = ?, name = ?, family = ?, ranking = ?,
			bool_use = ?, bool_aspect = ?, default_orbmod = ?, glyph = ?,
			comment = ? where _idx = ?;"""
		var = (self._num, self._name, self._family, self._bool_use,
			self._bool_aspect, self._default_orbmod, self._glyph,
			self._comment, self._idx_)
		try:
			db.execute(sql, var)
		except: # integrity error
			raise ValueError('Duplicate planet %s.' % self._name)
Exemplo n.º 27
0
	def _select_dict(self):
		"""Select filter dict in database, with filter idx."""
		sql = """select A.name, B.bool_asp from Planets as A,
		_AspectsRestrictions as B where B.filter_idx = ? and A._idx =
		B.planet_idx;"""
		res = db.execute(sql, (self._idx_,)).fetchall()
		self._set_dict(res)
Exemplo n.º 28
0
	def _update(self, recursive=False):
		"""Update filter in database.
		
		:type recursive: bool
		:raise ValueError: duplicate
		"""
		self._save_filters(recursive)
		sql = """update MidPointsFilters set name = ?, planets = ?, aspects = ?,
			orbs = ?, asprestr = ?, orbrestr = ?, comment = ? where _idx = ?;"""
		var = (self._name, self._planets._idx_, self._aspects._idx_,
			self._orbs._idx_, self._asprestr._idx_, self._orbrestr._idx_,
			self._comment, self._idx_)
		try:
			db.execute(sql, var)
		except: # integrity error
			raise ValueError('Duplicate filter %s.' % self._name)
Exemplo n.º 29
0
def load():
	"""Load configuration options from database (set globals)."""
	global username, usermail, language, atlas_db, charts_dir
	global use_docutils, use_hg, hg_repo, hg_user, hg_pswd
	global dft_name, dft_location, dft_country, dft_zoneinfo
	global dft_timezone, dft_latitude, dft_longitude, dft_altitude
	global dft_comment, dft_filter
	# load
	sql = "select * from Config;"
	res = db.execute(sql).fetchone()
	# set options
	username = res[0]
	usermail = res[1]
	language = res[2]
	atlas_db = res[3]
	charts_dir = res[4]
	use_docutils = bool(res[5])
	use_hg = bool(res[6])
	hg_repo = res[7]
	hg_user = res[8]
	hg_pswd = res[9]
	dft_name = res[10]
	dft_location = res[11]
	dft_country = res[12]
	if res[13] not in pytz.all_timezones:
		raise ValueError('Invalid timezone %s.' % res[13])
	else:
		dft_zoneinfo = res[13]
	dft_timezone = timezone.get(res[14]) if res[14] != '' else None
	dft_latitude = geocoords.Latitude(*res[15].split(':'))
	dft_longitude = geocoords.Longitude(*res[16].split(':'))
	dft_altitude = geocoords.Altitude(int(res[17]))
	dft_comment = res[18]
	dft_filter = Filter(int(res[19]))
Exemplo n.º 30
0
    def _select_dict(self):
        """Select filter dict in database, with filter idx."""
        sql = """select A.name, B.bool_asp from Planets as A,
		_AspectsRestrictions as B where B.filter_idx = ? and A._idx =
		B.planet_idx;"""
        res = db.execute(sql, (self._idx_, )).fetchall()
        self._set_dict(res)
Exemplo n.º 31
0
def load():
    """Load configuration options from database (set globals)."""
    global username, usermail, language, atlas_db, charts_dir
    global use_docutils, use_hg, hg_repo, hg_user, hg_pswd
    global dft_name, dft_location, dft_country, dft_zoneinfo
    global dft_timezone, dft_latitude, dft_longitude, dft_altitude
    global dft_comment, dft_filter
    # load
    sql = "select * from Config;"
    res = db.execute(sql).fetchone()
    # set options
    username = res[0]
    usermail = res[1]
    language = res[2]
    atlas_db = res[3]
    charts_dir = res[4]
    use_docutils = bool(res[5])
    use_hg = bool(res[6])
    hg_repo = res[7]
    hg_user = res[8]
    hg_pswd = res[9]
    dft_name = res[10]
    dft_location = res[11]
    dft_country = res[12]
    if res[13] not in pytz.all_timezones:
        raise ValueError('Invalid timezone %s.' % res[13])
    else:
        dft_zoneinfo = res[13]
    dft_timezone = timezone.get(res[14]) if res[14] != '' else None
    dft_latitude = geocoords.Latitude(*res[15].split(':'))
    dft_longitude = geocoords.Longitude(*res[16].split(':'))
    dft_altitude = geocoords.Altitude(int(res[17]))
    dft_comment = res[18]
    dft_filter = Filter(int(res[19]))
Exemplo n.º 32
0
	def _insert(self):
		"""Insert planet in database.
		
		:raise ValueError: duplicate
		"""
		sql1 = """insert into Planets (num, name, family, ranking, bool_use,
			bool_aspect, default_orbmod, glyph, comment) values (?, ?, ?,
			?, ?, ?, ?, ?);"""
		sql2 = "select _idx from Planets where num = ?;"
		var = (self._num, self._name, self._family, self._ranking,
			self._bool_use, self._bool_aspect, self._default_orbmod,
			self._glyph, self._comment)
		try:
			db.execute(sql1, var)
		except: # sqlite3.IntegrityError
			raise ValueError('Duplicate planet %s.' % self._name)
		self._idx = db.execute(sql2, (self._num,)).fetchone()[0]
Exemplo n.º 33
0
def all_orbs_restrictions_names():
    """Return a list of all orbs restrictions names."""
    ret = list()
    sql = 'select name from OrbsRestrictions order by name;'
    res = db.execute(sql).fetchall()
    for row in res:
        ret.append(row[0])
    return ret
Exemplo n.º 34
0
    def _insert(self):
        """Insert new aspect in database.
		
		:raise ValueError: duplicate
		"""
        sql1 = """insert into Aspects (name, angle, ranking,
			bool_use, default_orb, color, glyph, comment) values (?, ?,
			?, ?, ?, ?, ?, ?);"""
        sql2 = "select _idx from Aspects where name = ?;"
        var = (self._name, str(self._angle),
               self._ranking, int(self._bool_use), str(self._default_orb),
               str(self._color), self._glyph, self._comment)
        try:
            db.execute(sql1, var)
        except:  # sqlite3.IntegrityError
            raise ValueError('Duplicate filter %s.' % self._name)
        self._idx = db.execute(sql2, (self._name, )).fetchone()[0]
Exemplo n.º 35
0
def all_orbs_restrictions_names():
	"""Return a list of all orbs restrictions names."""
	ret = list()
	sql = 'select name from OrbsRestrictions order by name;'
	res = db.execute(sql).fetchall()
	for row in res:
		ret.append(row[0])
	return ret
Exemplo n.º 36
0
def save():
    """Save configuration options (globals) in database."""
    global username, usermail, language, atlas_db, charts_dir, dft_location
    global use_docutils, use_hg, hg_repo, hg_user, hg_pswd
    global dft_country, dft_zoneinfo, dft_timezone, dft_latitude
    global dft_longitude, dft_altitude, dft_filter
    # save
    sql = """update Config set username = ?, usermail = ?, language = ?,
		atlas_db = ?, charts_dir = ?, use_docutils = ?, use_hg = ?, hg_repo = ?,
		hg_user = ?, hg_pswd = ?, dft_location = ?, dft_country = ?,
		dft_zoneinfo = ?, dft_timezone = ?, dft_latitude = ?, dft_longitude = ?,
		dft_altitude = ?, dft_filter = ?;"""
    var = (username, usermail, language, atlas_db, charts_dir,
           int(use_docutils), int(use_hg), hg_repo, hg_user, hg_pswd,
           dft_location, dft_country, dft_zoneinfo,
           dft_timezone.utc if dft_timezone != None else '', str(dft_latitude),
           str(dft_longitude), dft_altitude, dft_filter._idx_)
    db.execute(sql, var)
Exemplo n.º 37
0
def save():
	"""Save configuration options (globals) in database."""
	global username, usermail, language, atlas_db, charts_dir, dft_location
	global use_docutils, use_hg, hg_repo, hg_user, hg_pswd
	global dft_country, dft_zoneinfo, dft_timezone, dft_latitude
	global dft_longitude, dft_altitude, dft_filter
	# save
	sql = """update Config set username = ?, usermail = ?, language = ?,
		atlas_db = ?, charts_dir = ?, use_docutils = ?, use_hg = ?, hg_repo = ?,
		hg_user = ?, hg_pswd = ?, dft_location = ?, dft_country = ?,
		dft_zoneinfo = ?, dft_timezone = ?, dft_latitude = ?, dft_longitude = ?,
		dft_altitude = ?, dft_filter = ?;"""
	var = (username, usermail, language, atlas_db, charts_dir,
		int(use_docutils), int(use_hg), hg_repo, hg_user, hg_pswd,
		dft_location, dft_country, dft_zoneinfo,
		dft_timezone.utc if dft_timezone != None else '', str(dft_latitude),
		str(dft_longitude), dft_altitude, dft_filter._idx_)
	db.execute(sql, var)
Exemplo n.º 38
0
def all_orbs_restrictions():
	"""Get list of all orbs filters objects."""
	ret = OrbsRestrictionsList()
	sql = "select * from OrbsRestrictions order by name;"
	res = db.execute(sql).fetchall()
	for row in res:
		ret.append(OrbsRestrictions(set_default=False))
		ret[-1].set(*row)
		ret[-1]._select_dict()
	return ret
Exemplo n.º 39
0
def all_orbs_restrictions():
    """Get list of all orbs filters objects."""
    ret = OrbsRestrictionsList()
    sql = "select * from OrbsRestrictions order by name;"
    res = db.execute(sql).fetchall()
    for row in res:
        ret.append(OrbsRestrictions(set_default=False))
        ret[-1].set(*row)
        ret[-1]._select_dict()
    return ret
Exemplo n.º 40
0
	def _insert(self, recursive=False):
		"""Insert filter in database.
		
		:type recursive: bool
		:raise ValueError: duplicate
		"""
		self._save_filters(recursive)
		sql1 = """insert into MidPointsFilters (name, planets,
			aspects, orbs, asprestr, orbrestr, comment) values (?, ?, ?, ?, ?,
			?, ?);"""
		var = (self._name, self._planets._idx_, self._aspects._idx_,
			self._orbs._idx_, self._asprestr._idx_, self._orbrestr._idx_,
			self._comment)
		sql2 = "select _idx from MidPointsFilters where name = ?;"
		try:
			db.execute(sql1, var)
		except: # sqlite3.IntegrityError
			raise ValueError('Duplicate filter %s.' % self._name)
		self._idx = db.execute(sql2,(self._name,)).fetchone()[0]
Exemplo n.º 41
0
	def _select_by_name(self, filt):
		"""Select filter in database, by name.
		
		:type filt: str
		:raise ValueError: not found
		"""
		sql = "select * from Filters where name = ?;"
		res = db.execute(sql, (filt,)).fetchall()
		if len(res) == 0:
			raise ValueError('Invalid filter %s.' % filt)
		self.set(*res[0])
Exemplo n.º 42
0
	def _select_by_idx(self, idx):
		"""Select filter in database, by idx.
		
		:type idx: int
		:raise ValueError: not found
		"""
		sql = "select * from Filters where _idx = ?;"
		res = db.execute(sql, (idx,)).fetchall()
		if len(res) == 0:
			raise ValueError('Invalid idx %s.' % idx)
		self.set(*res[0])
Exemplo n.º 43
0
def all_orbs_filters_names():
    """Return a list of all orbs filters names.
	
	:rtype: list
	"""
    ret = list()
    sql = 'select name from OrbsFilters order by name;'
    res = db.execute(sql).fetchall()
    for row in res:
        ret.append(row[0])
    return ret
Exemplo n.º 44
0
	def _select_by_name(self, filt):
		"""Select aspects restrictions filter in database, by name.
		
		:raise ValueError: not found
		"""
		sql = "select * from AspectsRestrictions where name = ?;"
		res = db.execute(sql, (filt,)).fetchall()
		if len(res) == 0:
			raise ValueError('Invalid filter %s.' % filt)
		self.set(*res[0])
		self._select_dict()
Exemplo n.º 45
0
def all_aspects_restrictions_names():
	"""Return a list of all aspects restrictions names.
	
	:rtype: list
	"""
	ret = list()
	sql = 'select name from AspectsRestrictions order by name;'
	res = db.execute(sql).fetchall()
	for row in res:
		ret.append(row[0])
	return ret
Exemplo n.º 46
0
def all_planets_names():
	"""Return a list of all planets names.
	
	:rtype: list
	"""
	ret = list()
	sql = 'select name from Planets order by ranking;'
	res = db.execute(sql).fetchall()
	for row in res:
		ret.append(row[0])
	return ret
Exemplo n.º 47
0
def all_aspects_names():
    """Return a list of all aspects names.
	
	:rtype: list
	"""
    ret = list()
    sql = 'select name from Aspects order by ranking, angle;'
    res = db.execute(sql).fetchall()
    for row in res:
        ret.append(row[0])
    return ret
Exemplo n.º 48
0
    def _select_by_idx(self, idx):
        """Select aspects filter in database, by idx.
		
		:raise ValueError: not found
		"""
        sql = "select * from AspectsFilters where _idx = ?;"
        res = db.execute(sql, (idx, )).fetchall()
        if len(res) == 0:
            raise ValueError('Invalid idx %s.' % idx)
        self.set(*res[0])
        self._select_dict()
Exemplo n.º 49
0
    def _select_by_name(self, filt):
        """Select aspects filter in database, by name.
		
		:raise ValueError: not found
		"""
        sql = "select * from AspectsFilters where name = ?;"
        res = db.execute(sql, (filt, )).fetchall()
        if len(res) == 0:
            raise ValueError('Invalid filter %s.' % filt)
        self.set(*res[0])
        self._select_dict()
Exemplo n.º 50
0
    def _select_by_angle(self, angle):
        """Select aspect from database, with angle (PiAngle).
		
		:type angle: PiAngle
		:raise ValueError: not found
		"""
        sql = "select * from Aspects where angle = ?;"
        res = db.execute(sql, (angle, )).fetchall()
        if len(res) == 0:
            raise ValueError('Invalid angle %s.' % angle)
        return self.set(*res[0])
Exemplo n.º 51
0
	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])
Exemplo n.º 52
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()
		if len(res) == 0:
			raise ValueError('Invalid planet name: %s.' % planet)
		self.set(*res[0])
Exemplo n.º 53
0
	def _select_by_num(self, num):
		"""Select a planet definition in database (by swisseph num).
		
		:type num: int
		:raise ValueError: not found
		"""
		sql = "select * from Planets where num = ?;"
		res = db.execute(sql, (num,)).fetchall()
		if len(res) == 0:
			raise ValueError('Invalid swisseph num: %s' % num)
		self.set(*res[0])
Exemplo n.º 54
0
def all_filters_names():
	"""Return a list of all filters names.
	
	:rtype: list
	"""
	ret = list()
	sql = 'select name from Filters order by name;'
	res = db.execute(sql).fetchall()
	for row in res:
		ret.append(row[0])
	return ret
Exemplo n.º 55
0
    def _select_by_name(self, aspect):
        """Select aspect from database, with name.
		
		:type aspect: str
		:raise ValueError: not found
		"""
        sql = "select * from Aspects where name = ?;"
        res = db.execute(sql, (aspect, )).fetchall()
        if len(res) == 0:
            raise ValueError('Invalid aspect %s.' % aspect)
        return self.set(*res[0])