Merge pull request #231 from AndreaCrotti/master

various small improvements
This commit is contained in:
Alexis Metaireau 2012-03-09 09:04:16 -08:00
commit 174f1b50c8
2 changed files with 31 additions and 22 deletions

View file

@ -4,27 +4,36 @@ from logging import CRITICAL, ERROR, WARN, INFO, DEBUG
from logging import critical, error, info, warning, warn, debug from logging import critical, error, info, warning, warn, debug
from logging import Formatter, getLogger, StreamHandler from logging import Formatter, getLogger, StreamHandler
global ANSI
ANSI = { RESET_TERM = u'\033[1;m'
'gray' : lambda(text) : u'\033[1;30m' + unicode(text) + u'\033[1;m',
'red' : lambda(text) : u'\033[1;31m' + unicode(text) + u'\033[1;m',
'green' : lambda(text) : u'\033[1;32m' + unicode(text) + u'\033[1;m', def term_color(code):
'yellow' : lambda(text) : u'\033[1;33m' + unicode(text) + u'\033[1;m', return lambda text: code + unicode(text) + RESET_TERM
'blue' : lambda(text) : u'\033[1;34m' + unicode(text) + u'\033[1;m',
'magenta' : lambda(text) : u'\033[1;35m' + unicode(text) + u'\033[1;m',
'cyan' : lambda(text) : u'\033[1;36m' + unicode(text) + u'\033[1;m', COLOR_CODES = {
'white' : lambda(text) : u'\033[1;37m' + unicode(text) + u'\033[1;m', 'gray': u'\033[1;30m',
'bgred' : lambda(text) : u'\033[1;41m' + unicode(text) + u'\033[1;m', 'red': u'\033[1;31m',
'bggreen' : lambda(text) : u'\033[1;42m' + unicode(text) + u'\033[1;m', 'green': u'\033[1;32m',
'bgbrown' : lambda(text) : u'\033[1;43m' + unicode(text) + u'\033[1;m', 'yellow': u'\033[1;33m',
'bgblue' : lambda(text) : u'\033[1;44m' + unicode(text) + u'\033[1;m', 'blue': u'\033[1;34m',
'bgmagenta' : lambda(text) : u'\033[1;45m' + unicode(text) + u'\033[1;m', 'magenta': u'\033[1;35m',
'bgcyan' : lambda(text) : u'\033[1;46m' + unicode(text) + u'\033[1;m', 'cyan': u'\033[1;36m',
'bggray' : lambda(text) : u'\033[1;47m' + unicode(text) + u'\033[1;m', 'white': u'\033[1;37m',
'bgyellow' : lambda(text) : u'\033[1;43m' + unicode(text) + u'\033[1;m', 'bgred': u'\033[1;41m',
'bggrey' : lambda(text) : u'\033[1;100m' + unicode(text) + u'\033[1;m' 'bggreen': u'\033[1;42m',
'bgbrown': u'\033[1;43m',
'bgblue': u'\033[1;44m',
'bgmagenta': u'\033[1;45m',
'bgcyan': u'\033[1;46m',
'bggray': u'\033[1;47m',
'bgyellow': u'\033[1;43m',
'bggrey': u'\033[1;100m',
} }
ANSI = dict((col, term_color(code)) for col, code in COLOR_CODES.items())
class ANSIFormatter(Formatter): class ANSIFormatter(Formatter):
""" """

View file

@ -71,7 +71,7 @@ def dc2fields(file):
else: else:
posts.append(line) posts.append(line)
print "%i posts read." % len(posts) print("%i posts read." % len(posts))
for post in posts: for post in posts:
fields = post.split('","') fields = post.split('","')
@ -205,7 +205,7 @@ def fields2pelican(fields, out_markup, output_path, dircat=False):
else: else:
out_filename = os.path.join(output_path, filename+ext) out_filename = os.path.join(output_path, filename+ext)
print out_filename print(out_filename)
if in_markup == "html": if in_markup == "html":
html_filename = os.path.join(output_path, filename+'.html') html_filename = os.path.join(output_path, filename+'.html')
@ -259,7 +259,7 @@ def main():
elif args.feed: elif args.feed:
input_type = 'feed' input_type = 'feed'
else: else:
print "you must provide either --wpfile, --dotclear or --feed options" print("you must provide either --wpfile, --dotclear or --feed options")
exit() exit()
if not os.path.exists(args.output): if not os.path.exists(args.output):