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
def init(self,app): self.datab.connect(app) self.epheflag = 4 self.country = '' self.usa = False self.orbs = [] self.peorbs = [] self.transits = [] self.master = chart.Chart('master') self.click = chart.Chart('click') self.now = chart.Chart('now') self.now.first = _('Momento actual') self.calc = chart.Chart('calc') self.loc = Locality() self.date = NeXDate(self) self.calcdt = NeXDate(self) self.person = PersonInfo() self.charts = { 'master' : self.master, 'click' : self.click, 'now' : self.now, 'calc' : self.calc } self.curr_chart = None self.curr_click = None self.crossed = True # False! self.opmode = 'simple' self.curr_op = 'draw_nat' self.opright = 'draw_house' self.opleft = 'draw_nat' self.opup = 'draw_nat' self.clickmode = 'master' self.curr_list = opdouble self.pool = deque([]) file = path.joinpath(app.home_dir,'mruch.pkl') if path.exists(file): input = open(file,"rb") self.pool = pickle.load(input) self.couples = [] self.coup_ix = 0 file = path.joinpath(app.home_dir,'coups.pkl') if path.exists(file): input = open(file,"rb") self.couples = pickle.load(input) self.fav = [] self.fav_ix = 0
def read_config(homedir): global cfgcols cfgfile = path.joinpath(homedir,'cfg.ini') conf = ConfigObj(cfgfile) popts = {} for k in conf.keys(): popts.update(conf[k]) if popts.has_key('transits') and not isinstance(popts['transits'],list): del popts['transits'] opts = NexConf() opts.__dict__.update(popts) for keyc in default_colors.keys(): val = getattr(opts,keyc) cfgcols[keyc] = ''.join(['#',val]) if not path.exists(cfgfile) or len(opts.__dict__) != popts: opts.opts_to_config(conf) conf.write() return opts