Skip to content

Instantly share code, notes, and snippets.

@dnng
Last active March 21, 2018 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnng/8bd7839470e6843e5fbfb0ebd122da57 to your computer and use it in GitHub Desktop.
Save dnng/8bd7839470e6843e5fbfb0ebd122da57 to your computer and use it in GitHub Desktop.
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')
@jbarguil
Copy link

Formatando melhor e deixando a função mais desacoplada das variÑveis globais:

def lutti_to_unicode(lutti, upper=False):
    """Luttifies a lutti."""
    return ''.join(map(
        lambda l: d.get(l, l), 
        lutti.upper() if upper else lutti
    ))

AΓ­ tem que passar o args.uppercase na chamada

@dnng
Copy link
Author

dnng commented Mar 21, 2018

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