Restore compatibility with Python 2.0

git-svn-id: http://svn.pyinstaller.org/trunk@111 8dd32b29-ccff-0310-8a9a-9233e24343b1
This commit is contained in:
giovannibajo
2005-09-21 11:34:42 +00:00
parent c220fdcca4
commit faed75cbbc
3 changed files with 12 additions and 16 deletions
+1 -1
View File
@@ -272,7 +272,7 @@ class Option:
self.type = "string"
else:
# Allow type objects as an alternative to their names.
if type(self.type) is type:
if hasattr(self.type, "__name__"):
self.type = self.type.__name__
if self.type == "str":
self.type = "string"
+8 -13
View File
@@ -27,11 +27,9 @@ try:
True, False
except NameError:
(True, False) = (1, 0)
try:
basestring
except NameError:
basestring = (str, unicode)
def isbasestring(x):
return isinstance(x, types.StringType) or isinstance(x, types.UnicodeType)
class Values:
@@ -45,16 +43,13 @@ class Values:
__repr__ = _repr
def __eq__(self, other):
def __cmp__(self, other):
if isinstance(other, Values):
return self.__dict__ == other.__dict__
elif isinstance(other, dict):
return self.__dict__ == other
return cmp(self.__dict__, other.__dict__)
elif isinstance(other, types.DictType):
return cmp(self.__dict__, other)
else:
return False
def __ne__(self, other):
return not (self == other)
return -1
def _update_careful(self, dict):
"""
@@ -480,7 +475,7 @@ class OptionParser (OptionContainer):
defaults = self.defaults.copy()
for option in self._get_all_options():
default = defaults.get(option.dest)
if isinstance(default, basestring):
if isbasestring(default):
opt_str = option.get_opt_string()
defaults[option.dest] = option.check_value(opt_str, default)
+3 -2
View File
@@ -8,6 +8,7 @@
__revision__ = "$Id: textwrap.py,v 1.35 2004/06/03 01:59:40 gward Exp $"
import string, re
import types
# Do the right thing with boolean values for all known Python versions
# (so this module can be copied to projects that don't depend on Python
@@ -120,9 +121,9 @@ class TextWrapper:
if self.expand_tabs:
text = text.expandtabs()
if self.replace_whitespace:
if isinstance(text, str):
if isinstance(text, types.StringType):
text = text.translate(self.whitespace_trans)
elif isinstance(text, unicode):
elif isinstance(text, types.UnicodeType):
text = text.translate(self.unicode_whitespace_trans)
return text