Last active
March 21, 2018 06:19
-
-
Save dnng/8bd7839470e6843e5fbfb0ebd122da57 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import logging | |
VERSION = '3.0' | |
parser = argparse.ArgumentParser(description='Luttify your messages') | |
parser.add_argument('message', metavar='message', type=str, | |
help='add a Lutti to be Luttified') | |
parser.add_argument('-up', '--uppercase', action='store_true', | |
default=False, dest='uppercase', | |
help='outputs Lutti\'s message as it should be') | |
parser.add_argument('-V', '--version', action='version', | |
version='%(prog)s ' + VERSION) | |
parser.add_argument('-v', '--verbose', help='enables verbose outpus', | |
dest='loglevel', choices=['INFO', 'WARNING', 'ERROR', | |
'CRITICAL'], default='CRITICAL') | |
parser.add_argument('-d', '--debug', help='Lutti needs help!', | |
action="store_const", const=logging.DEBUG, | |
dest='loglevel', default='CRITICAL') | |
args = parser.parse_args() | |
logging.basicConfig(level=logging.getLevelName(args.loglevel)) | |
d = { "A":"π°", "B":"π±", "C":"π²", "D":"π³", "E":"π΄", "F":"π΅", "G":"πΆ", "H":"π·", | |
"I":"πΈ", "J":"πΉ", "K":"πΊ", "L":"π»", "M":"πΌ", "N":"π½", "O":"πΎ", "P":"πΏ", | |
"Q":"π", "R":"π", "S":"π", "T":"π", "U":"π", "V":"π ", "W":"π", "X":"π", | |
"Y":"π", "Z":"π", "a":"π", "b":"π", "c":"π", "d":"π", "e":"π", "f":"π", | |
"g":"π", "h":"π", "i":"π", "j":"π", "k":"π", "l":"π", "m":"π", "n":"π", | |
"o":"π", "p":"π", "q":"π", "r":"π", "s":"π", "t":"π", "u":"π", "v":"π", | |
"w":"π ", "x":"π‘", "y":"π’", "z":"π£", "0":"πΆ", "1":"π·", "2":"πΈ", "3":"πΉ", | |
"4":"πΊ", "5":"π»", "6":"πΌ", "7":"π½", "8":"πΎ", "9":"πΏ" } | |
def lutti_to_unicode(lutti, upper=False): | |
logging.info("Luttifying message...") | |
logging.warning('Using functional state of the art programming..') | |
logging.debug('Entering lutti_to_unicode') | |
return ''.join(map( | |
lambda l: d.get(l, l), | |
lutti.upper() if upper else lutti | |
)) | |
print(lutti_to_unicode(args.message, args.uppercase)) | |
logging.info('Luttifying complete!') | |
logging.warning('End of program') | |
logging.debug('Any bugs in this code are left as an excercise to the reader') |
Feito!
(...) mais desacoplada das variΓ‘veis globais
A ΓΊnica global var Γ© VERSION
, o resto vem de args
, mas eu entendi o que vc quis dizer ;-)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Formatando melhor e deixando a funΓ§Γ£o mais desacoplada das variΓ‘veis globais:
AΓ tem que passar o args.uppercase na chamada