tidied
This commit is contained in:
parent
40328cf24f
commit
05a68faf1d
|
@ -42,21 +42,21 @@ def urban(inp):
|
||||||
if id_num:
|
if id_num:
|
||||||
# try getting the requested definition
|
# try getting the requested definition
|
||||||
try:
|
try:
|
||||||
definition = definitions[id_num - 1]['definition'].replace('\r\n', ' ')
|
definition = definitions[id_num - 1]
|
||||||
definition = re.sub('\s+', ' ', definition).strip() # remove excess spaces
|
|
||||||
definition = text.truncate_str(definition, 200)
|
def_text = " ".join(definition['definition'].split()) # remove excess spaces
|
||||||
|
def_text = text.truncate_str(def_text, 200)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return 'Not found.'
|
return 'Not found.'
|
||||||
|
|
||||||
url = definitions[id_num - 1]['permalink']
|
url = definition['permalink']
|
||||||
output = u"[%i/%i] %s :: %s" % \
|
output = u"[%i/%i] %s :: %s" % \
|
||||||
(id_num, len(definitions), definition, url)
|
(id_num, len(definitions), def_text, url)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
definition = random.choice(definitions)
|
definition = random.choice(definitions)
|
||||||
|
|
||||||
def_text = definition['definition'].replace('\r\n', ' ')
|
def_text = " ".join(definition['definition'].split()) # remove excess spaces
|
||||||
def_text = re.sub('\s+', ' ', def_text).strip() # remove excess spaces
|
|
||||||
def_text = text.truncate_str(def_text, 200)
|
def_text = text.truncate_str(def_text, 200)
|
||||||
|
|
||||||
name = definition['word']
|
name = definition['word']
|
||||||
|
|
Reference in New Issue