def gotResults_inoops2(self, words, fullResults): if self.lastResObj: fstring = '' if self.hasCommon(words, 'Cancel'): natqh.Wait() self.cancelMode() natqh.returnFromMessagesWindow() return fNum = string.atoi(words[-1]) if fNum in FORMATS.keys(): fstring = FORMATS[fNum] else: print 'invalid paramter choosen: %s' % ` words ` fstring = '' if fstring and self.newWord: oldFormat = natlink.getWordInfo(self.newWord) if fstring == oldFormat: print 'format of %s is already: %x' % (self.newWord, fstring) else: print 'formatting word: %s from hex %x to hex: %x' % ( self.newWord, oldFormat, fstring) natlink.setWordInfo(self.newWord, fstring) self.newWord = "" time.sleep(1.0) self.cancelMode() natqh.returnFromMessagesWindow()
def set_word_properties(name, properties): old_flags = natlink.getWordInfo(name, 0) if old_flags == None: raise natlink.UnknownName flags = apply_properties(properties, old_flags) if flags == old_flags: return print "changing properties of '%s' to 0x%x" % (name, flags) print " from 0x%x" % old_flags natlink.setWordInfo(name, flags) if natlink.getWordInfo(name, 0) != flags: print "FAILED! properties remain 0x%x" % natlink.getWordInfo(name, 0)
def gotResults_batch(self,words,fullResults): files = [f[:-4] for f in os.listdir(wordsFolder)] if files: print 'in folder: %s, files: %s'% (wordsFolder, files) else: print 'in folder: %s, no files found'% wordsFolder return for f in files: F = f + '.txt' if f == 'deleted words': print 'delete words!' for l in open(os.path.join(wordsFolder, F)): w = l.strip() if w.find('\\\\') > 0: w, p = w.split('\\\\') print f, ', word to delete :', w natqh.deleteWordIfNecessary(w) continue if f in FORMATS: formatting = FORMATS[f] print 'to formatting for file: %s: %x'% (f, formatting) else: print 'no formatting information for file: %s'% f formatting = 0 for l in open(os.path.join(wordsFolder, F)): p = 0 # possibly user defined properties w = l.strip() print f, ', word:', w if w.find('\\\\') > 0: w, p = w.split('\\\\') exec("p = %s"%p) ## pList = natqh.ListOfProperties(p) ## for pp in pList: ## print pp newFormat = p or formatting natqh.addWordIfNecessary(w) formatOld = natlink.getWordInfo(w) if formatOld == newFormat: print 'format already okay: %s (%x)'% (w, newFormat) else: natlink.setWordInfo(w, newFormat) print 'format set for %s: %x'% (w, newFormat)
def gotResults_batch(self, words, fullResults): files = [f[:-4] for f in os.listdir(wordsFolder)] if files: print 'in folder: %s, files: %s' % (wordsFolder, files) else: print 'in folder: %s, no files found' % wordsFolder return for f in files: F = f + '.txt' if f == 'deleted words': print 'delete words!' for l in open(os.path.join(wordsFolder, F)): w = l.strip() if w.find('\\\\') > 0: w, p = w.split('\\\\') print f, ', word to delete :', w natqh.deleteWordIfNecessary(w) continue if f in FORMATS: formatting = FORMATS[f] print 'to formatting for file: %s: %x' % (f, formatting) else: print 'no formatting information for file: %s' % f formatting = 0 for l in open(os.path.join(wordsFolder, F)): p = 0 # possibly user defined properties w = l.strip() print f, ', word:', w if w.find('\\\\') > 0: w, p = w.split('\\\\') exec("p = %s" % p) ## pList = natqh.ListOfProperties(p) ## for pp in pList: ## print pp newFormat = p or formatting natqh.addWordIfNecessary(w) formatOld = natlink.getWordInfo(w) if formatOld == newFormat: print 'format already okay: %s (%x)' % (w, newFormat) else: natlink.setWordInfo(w, newFormat) print 'format set for %s: %x' % (w, newFormat)