Exemplo n.º 1
0
 def loaddb(self):
   # load every artist file
   for subdir, dirs, files in os.walk(os.path.join(os.path.dirname(__file__), "../data/")):
     for f in files:
       if ArtistWords.get_by_key_name(f):
         self.response.out.write('Skipping ')
         continue
       try:
         path = os.path.join(
           os.path.dirname(__file__), "../data/" + f
         )
         df = open(path, 'r')
       except IOError:
         continue
       else:
         aname = unicode(df.readline().rstrip(), 'utf-8')
         lyr = ArtistWords(key_name=aname, name=aname, words=unicode(df.read(), 'utf-8'))
         lyr.put()
         df.close()