def cd_data_dir(): assert sys.argv prefix_path = os.path.dirname(sys.argv[0]) local_data = os.path.join(prefix_path, "data") if os.path.exists(os.path.join(local_data, "style.css")): data_dir = local_data else: data_dir = appdata_dir() QDir.setCurrent(data_dir)
def init_headers_file(self): filename = self.path() if os.path.exists(filename): return src = os.path.join(appdata_dir(), 'blockchain_headers') if os.path.exists(src): # copy it from appdata dir print_error( "copying headers to", filename ) shutil.copy(src, filename) else: print_error( "creating headers file", filename ) open(filename,'wb+').close()
def __init__(self, lang='en'): filename = filenames.get(lang[0:2], 'english.txt') path = os.path.join(util.appdata_dir(), 'wordlist', filename) s = open(path,'r').read().strip() s = unicodedata.normalize('NFKD', s.decode('utf8')) lines = s.split('\n') self.wordlist = [] for line in lines: line = line.split('#')[0] line = line.strip(' \r') assert ' ' not in line if line: self.wordlist.append(line) print_error("wordlist has %d words"%len(self.wordlist))
def load_theme_paths(): theme_paths = {} prefixes = (util.local_data_dir(), util.appdata_dir()) for prefix in prefixes: theme_paths.update(theme_dirs_from_prefix(prefix)) return theme_paths