def main(argv): sum = 0.0 for val in [l.strip() for l in sys.stdin.readlines()]: try: number = float(val) sum += number except ValueError as detail: epp.err("Error on value " + val + " " + str(detail)) epp.write("Somme = %f" % sum)
def main(argv): app = TkWordsList() app.add_words(('bonjour', 'monsieur', 'le', 'chien')) app.add_words(('bonsoir', 'madame', 'la', 'vache'), tabName="TEST") app.select_word('mon') app.mainloop() if app.choix != None: epp.write(app.choix)
wordNormalized = NL + wordNormalized sqlNorm = re.sub('(?i)' + aloner(word), wordNormalized, sqlNorm) epp.log(sqlNorm) sqlNorm = normalizeOperators(sqlNorm) epp.log ('-----') epp.log(sqlNorm) sections = sqlNorm.splitlines() sectionsNorm = list() for section in [e for e in sections if e != '' ]: sectionNorm = normalizeSection(section, NL, MAX_WIDTH) sectionsNorm.append(sectionNorm) return NL.join(sectionsNorm) if __name__=='__main__': parser = optparse.OptionParser() parser.add_option("-f","--fileName",action="store",type="string",dest="filename",help="SQL file to beautify") parser.add_option("-u","--uppercase",action="store_true",dest="uppercase",default=False,help="Change keyword to uppercase") (options, args) = parser.parse_args() if options.filename: epp.err('not implemented yet') else: rawSQL = sys.stdin.read() epp.write(tidySQL(rawSQL, options.uppercase)) sys.exit(0)
def main(argv): parser = optparse.OptionParser() parser.add_option("-c","--cursor",action="store",type="int",dest="cursor",help="Cursor position in file (byte)") parser.add_option("-f","--fileName",action="store",type="string",dest="filename",help="File to parse") parser.add_option("-l","--currLine",action="store",type="int",dest="currline",help="Current line in the file") parser.add_option("-t","--type",action="store",type="string",dest="type",help="File type (extension without dot)") parser.add_option("-w","--width",action="store",type="int",dest="width",help="How many lines to scan above and below the current line. 0 -> whole file (Optional)") parser.add_option("--language",action="store",type="string",dest="language",help="The language file to use to get keywords (Optional)") parser.set_defaults(width=0) (options, args) = parser.parse_args(argv) epp.log("cursor:%s, currLine:%s, width:%s" % (options.cursor, options.currline, options.width)) if options.filename and options.currline and options.cursor: epp.log(options.filename) # DEBUG Parfois le programme ne trouve pas le bon terme à chercher... if DEBUG_FILE: distutils.file_util.copy_file(options.filename, os.path.join(os.environ["TMP"], "EPP_TMP.txt")) # Check UTF8 codecName = epp.getFileCodecName(options.filename) epp.log("codec detecté: %s" % codecName) if codecName == "utf_8": options.cursor += 3 with open(options.filename, 'r', encoding=codecName) as fileh: # Recuperation des lettres precedants le curseur search = ac.get_search(fileh, options.cursor) epp.log("Search for %s...\n--------------" % search) # Taille minimum du mot de recherche if len(search) <= 1: epp.log("Search term too little, 2 letters minimum") sys.exit(1) # Scan du fichier pour retrouver les candidats file_words = ac.get_file_words(search, fileh, options.currline, options.width) language = ac.get_language(options.language, options.type) if language: # Récupération de la liste des mots du langage lang_words = ac.get_language_words(search, language) else: lang_words = set() # MAJ des mots du fichier étant également des mots du language for wordObj in [w for w in file_words if w in lang_words]: wordObj.color = "blue" # on supprime les mots du langage appartenant deja au fichier (pour garder les caracteristiques du mot) lang_words = lang_words - file_words for wordObj in lang_words: wordObj.color = "blue" nb_words = len(lang_words) + len(file_words) # Affichage du résultat if nb_words == 1: # 1 seul candidat -> on l'utilise epp.write(ac.get_result(search, (lang_words | file_words).pop())) elif nb_words > 1: # Plusieurs candidats : Affichage des candidats choix = choix_liste_mots(search, lang_words, file_words) if choix != None: epp.write(ac.get_result(search, choix)) else: # Aucun candidat #import winsound #winsound.MessageBeep(winsound.MB_ICONEXCLAMATION); epp.log("Aucun candidat trouve") # Ajout d'un espace pour montrer que rien n'a été trouvé epp.write(' ') sys.exit() else: # On provoque une erreur if not options.filename: parser.error("filename") elif not options.currline: parser.error("currline") elif not options.cursor: parser.error("cursor") sys.exit(1)
import sys import win32clipboard as w import epp_utils as epp if __name__ == "__main__": # TODO Gérer les différents encodage de chaîne w.OpenClipboard() clipboardText = w.GetClipboardData() w.CloseClipboard() # TODO Prendre en compte le type de saut de ligne newLine = "\n" lines = clipboardText.splitlines() for l in lines: epp.write(l + newLine)