Skip to content

Commit

Permalink
Normalize unicode handling only around author
Browse files Browse the repository at this point in the history
  • Loading branch information
brutasse committed Oct 21, 2013
1 parent 0ba9ae0 commit 0c8a957
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions lib/fpm/package/pyfpm/get_metadata.py
@@ -1,13 +1,23 @@
from __future__ import unicode_literals

from distutils.core import Command
import os
import sys
import pkg_resources
try:
import json
except ImportError:
import simplejson as json

PY3 = sys.version_info[0] == 3

if PY3:
def u(s):
return s
else:
def u(s):
if isinstance(u, unicode):
return u
return s.decode('utf-8')


# Note, the last time I coded python daily was at Google, so it's entirely
# possible some of my techniques below are outdated or bad.
Expand Down Expand Up @@ -50,9 +60,9 @@ def run(self):
data = {
"name": self.distribution.get_name(),
"version": self.distribution.get_version(),
"author": "%s <%s>" % (
self.distribution.get_author(),
self.distribution.get_author_email(),
"author": u("%s <%s>") % (
u(self.distribution.get_author()),
u(self.distribution.get_author_email()),
),
"description": self.distribution.get_description(),
"license": self.distribution.get_license(),
Expand Down

0 comments on commit 0c8a957

Please sign in to comment.