コード例 #1
0
ファイル: cfg.py プロジェクト: lycofron/oroboros
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]))
コード例 #2
0
ファイル: chartfile.py プロジェクト: lycofron/oroboros
    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
コード例 #3
0
ファイル: geonames.py プロジェクト: lycofron/oroboros
def search(name):
    """Query GeoNames.org.
	
	Return a list of tuples (name, country, lat, lon, elev, timezone)
	
	:type name: str
	:rtype: list
	"""
    url = 'http://ws.geonames.org/search?q=%s&featureClass=P&style=FULL'
    f = query(url % urllib.quote(name))
    xml = xmlutils.parse(f)
    try:
        f.close()
    except:
        pass
    ret = list()
    all = xml.get_iterator('geoname')
    for a in all:
        lat = geocoords.Latitude()
        lon = geocoords.Longitude()
        dlat = float(a.get_child_text(tag='lat'))
        dlon = float(a.get_child_text(tag='lng'))
        lat.from_decimal(dlat)
        lon.from_decimal(dlon)
        elev = get_elevation(dlat, dlon)
        ret.append(
            (a.get_child_text(tag='name'), a.get_child_text(tag='countryName'),
             lat, lon, elev, a.get_child_text(tag='timezone')))
    return ret
コード例 #4
0
ファイル: chartfile.py プロジェクト: lycofron/oroboros
    def _set_latitude(self, lat):
        """Set chart latitude.

        Accepts Latitude objects,
        or tuple with degrees/direction/minutes/seconds,
        or string with ':'-separated values, like '46:N:32:0'.

        :param lat: latitude
        :type lat: geocoords.Latitude or sequence or str
        :raise TypeError: latitude is invalid
        """
        if isinstance(lat, geocoords.Latitude):
            self._latitude = lat
        elif isinstance(lat, (tuple, list)):
            self._latitude = geocoords.Latitude(*lat)
        elif isinstance(lat, str):
            self._latitude = geocoords.Latitude(*lat.split(':'))
        else:
            raise TypeError('Invalid latitude %s.' % lat)
コード例 #5
0
ファイル: cfg.py プロジェクト: lycofron/oroboros
language = ''
atlas_db = '~/.oroboros/atlas.db'
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;"