Ejemplo n.º 1
0
 def setup(self):
     try:
         self.conf = configurator.load(self.loc)
     except IOError:
         raise IOError('A conf.py file is required for the %s game (fluogames.boggle) in %s' % (self.name, os.path.join(self.loc, 'conf.py')))
     self.reset_conf()
     self._loaded_wordlists = {}
     self.lang_conf = {}
     with util.indir(self.loc):
         for lang in os.listdir('.'):
             if os.path.isdir(lang) \
                     and os.path.exists(os.path.join(lang, 'conf.py')):
                 self.lang_conf[lang] = lang_configurator.load(lang)
Ejemplo n.º 2
0
 def load_wordlist(self, language):
     if language in self._loaded_wordlists:
         return self._loaded_wordlists[language]
     
     conf = self.get_lang_conf(language)
     with util.indir(self.loc):
         dict_file = os.path.join(language, 'dict.txt')
         if not os.path.exists(os.path.join(language, 'dict.txt')):
             print 'downloading %s' % language
             urllib.urlretrieve(conf['wordlist_url'], dict_file)
         with open(dict_file, 'r') as f:
             print 'reading %s' % dict_file
             words = frozenset(map(str.strip, f.readlines()))
             self._loaded_wordlists[language] = words
         return words