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]))
def __init__(self, path=None, set_default=True): """Load or create a (default) chart. :type path: str or None :type set_default: bool """ if path != None: self.parse(path) elif set_default: self.set_default() else: self._path = None self._name = '<?>' self._datetime = datetime.utcnow().replace(microsecond=0) self._calendar = 'gregorian' self._location = '<?>' self._latitude = geocoords.Latitude() self._longitude = geocoords.Longitude() self._altitude = geocoords.Altitude() self._country = '<?>' self._zoneinfo = None self._timezone = None self._comment = '' self._keywords = KeywordsDict() self._dst = None self._utcoffset = None
def _set_altitude(self, alt): """Set chart altitude. :type alt: geocoords.Altitude or numeric value >= 0 """ if isinstance(alt, geocoords.Altitude): self._altitude = alt else: self._altitude = geocoords.Altitude(alt)
def get_elevation(lat, lon): """Get elevation (altitude) for a place. :type lat: numeric :type lon: numeric :rtype: Altitude """ if lat > 60 or lat < -66: # use gtopo30 url = 'http://ws.geonames.org/gtopo30?lat=%s&lng=%s' else: # use srtm3 url = 'http://ws.geonames.org/srtm3?lat=%s&lng=%s' f = query(url % (lat, lon)) elev = int(f.read().strip()) try: f.close() except: pass if elev < 0: elev = 0 return geocoords.Altitude(elev)
charts_dir = '~' use_docutils = False use_hg = False hg_repo = 'http://hg.atarax.org/public' hg_user = '******' hg_pswd = 'password' dft_name = 'Here-Now' dft_location = 'Lausanne' dft_country = 'Switzerland' dft_zoneinfo = 'Europe/Zurich' dft_timezone = timezone.get('UTC+1') dft_latitude = geocoords.Latitude(46, 'N', 32) dft_longitude = geocoords.Longitude(6, 'E', 40) dft_altitude = geocoords.Altitude(400) dft_comment = '' dft_filter = Filter() 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