def easy_connect(): global local_conn, chart_conn, customloc_conn dbfile = "./db/local.db" local_conn = sqlite3.connect(str(dbfile)) local_conn.create_collation('westcoll', westerncollate) dbfile = path.joinpath(path.expanduser(path('~')),".astronex/charts.db") chart_conn = sqlite3.connect(dbfile) chart_conn.create_collation('westcoll', westerncollate) dbfile = path.joinpath(path.expanduser(path('~')),".astronex/customloc.db") sql = "attach database '%s' as custom" % (dbfile) local_conn.execute(sql)
def test(): import cairo surface = cairo.ImageSurface(cairo.FORMAT_ARGB32,100,100) context = cairo.Context(surface) config.read_config(path("/home/jose/.astronex")) zod = Zodiac(context) for z in zod.zod: print z.__dict__ print for z in zod.plan: print z.__dict__
def check_home_dir(appath): """Set home dir, copying needed files""" global home_dir, ephe_flag default_home = path.joinpath(path.expanduser(path("~")), home_dir) if not path.exists(default_home): path.mkdir(default_home) ephepath = path.joinpath(default_home, ephe_path) if not path.exists(ephepath): path.mkdir(path.joinpath(default_home, ephe_path)) path.copy(path.joinpath(appath, "astronex/resources/README"), ephepath) if ephepath.glob("*.se1"): ephe_flag = 2 if not path.exists(path.joinpath(default_home, default_db)): path.copy(path.joinpath(appath, "astronex/resources/charts.db"), default_home) home_dir = default_home
date,_,time = chart.date.partition('T') date = ".".join(reversed([d.lstrip('0') for d in date.split('-')])) time = time[:5] country = ccodes[datab.get_code_from_name(chart.country)] achunk = ",".join([a93,fname,sex,date,time,place,country]) return achunk def export_table(table): chlist = datab.get_chartlist(table) chart = Chart() chunks = [] for id,_,_ in chlist: datab.load_chart(tname, id, chart) chunks.append(export_chart(chart)) return chunks if __name__ == '__main__': datab.easy_connect() tname = 'personal' chunks = export_table(tname) aafile = path.joinpath(path.expanduser(path('~')),"%s.aaf" % tname) f = open(aafile,'w') for ch in chunks: f.write(ch.encode('utf-8')) f.write('\n') f.close() #print chunks