~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Lib/distutils/dist.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mto: (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100311133019-sblbooa3uqrkoe70
Tags: upstream-2.6.5~rc2
ImportĀ upstreamĀ versionĀ 2.6.5~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
# This module should be kept compatible with Python 2.1.
8
8
 
9
 
__revision__ = "$Id: dist.py 68035 2008-12-29 22:36:22Z tarek.ziade $"
 
9
__revision__ = "$Id: dist.py 77719 2010-01-24 00:57:20Z tarek.ziade $"
10
10
 
11
11
import sys, os, string, re
12
12
from types import *
1114
1114
        self._write_list(file, 'Obsoletes', self.get_obsoletes())
1115
1115
 
1116
1116
    def _write_field(self, file, name, value):
1117
 
 
1118
 
        if isinstance(value, unicode):
1119
 
            value = value.encode(PKG_INFO_ENCODING)
1120
 
        else:
1121
 
            value = str(value)
1122
 
        file.write('%s: %s\n' % (name, value))
 
1117
        file.write('%s: %s\n' % (name, self._encode_field(value)))
1123
1118
 
1124
1119
    def _write_list (self, file, name, values):
1125
1120
 
1126
1121
        for value in values:
1127
1122
            self._write_field(file, name, value)
1128
1123
 
 
1124
    def _encode_field(self, value):
 
1125
        if value is None:
 
1126
            return None
 
1127
        if isinstance(value, unicode):
 
1128
            return value.encode(PKG_INFO_ENCODING)
 
1129
        return str(value)
 
1130
 
1129
1131
    # -- Metadata query methods ----------------------------------------
1130
1132
 
1131
1133
    def get_name (self):
1138
1140
        return "%s-%s" % (self.get_name(), self.get_version())
1139
1141
 
1140
1142
    def get_author(self):
1141
 
        return self.author or "UNKNOWN"
 
1143
        return self._encode_field(self.author) or "UNKNOWN"
1142
1144
 
1143
1145
    def get_author_email(self):
1144
1146
        return self.author_email or "UNKNOWN"
1145
1147
 
1146
1148
    def get_maintainer(self):
1147
 
        return self.maintainer or "UNKNOWN"
 
1149
        return self._encode_field(self.maintainer) or "UNKNOWN"
1148
1150
 
1149
1151
    def get_maintainer_email(self):
1150
1152
        return self.maintainer_email or "UNKNOWN"
1151
1153
 
1152
1154
    def get_contact(self):
1153
 
        return (self.maintainer or
1154
 
                self.author or
1155
 
                "UNKNOWN")
 
1155
        return (self._encode_field(self.maintainer) or
 
1156
                self._encode_field(self.author) or "UNKNOWN")
1156
1157
 
1157
1158
    def get_contact_email(self):
1158
1159
        return (self.maintainer_email or
1167
1168
    get_licence = get_license
1168
1169
 
1169
1170
    def get_description(self):
1170
 
        return self.description or "UNKNOWN"
 
1171
        return self._encode_field(self.description) or "UNKNOWN"
1171
1172
 
1172
1173
    def get_long_description(self):
1173
 
        return self.long_description or "UNKNOWN"
 
1174
        return self._encode_field(self.long_description) or "UNKNOWN"
1174
1175
 
1175
1176
    def get_keywords(self):
1176
1177
        return self.keywords or []