git: c0583368636e - main - devel/py-optik: Fix build with setuptools 58.0.0+
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 25 Mar 2022 13:50:05 UTC
The branch main has been updated by sunpoet:
URL: https://cgit.FreeBSD.org/ports/commit/?id=c0583368636e5fc529eee68bec35838bea0913ea
commit c0583368636e5fc529eee68bec35838bea0913ea
Author: Po-Chuan Hsieh <sunpoet@FreeBSD.org>
AuthorDate: 2022-03-25 13:32:19 +0000
Commit: Po-Chuan Hsieh <sunpoet@FreeBSD.org>
CommitDate: 2022-03-25 13:38:10 +0000
devel/py-optik: Fix build with setuptools 58.0.0+
With hat: python
---
devel/py-optik/files/patch-2to3 | 352 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 352 insertions(+)
diff --git a/devel/py-optik/files/patch-2to3 b/devel/py-optik/files/patch-2to3
new file mode 100644
index 000000000000..1103787507b8
--- /dev/null
+++ b/devel/py-optik/files/patch-2to3
@@ -0,0 +1,352 @@
+--- lib/help.py.orig 2006-07-23 15:21:30 UTC
++++ lib/help.py
+@@ -8,7 +8,7 @@ to generate formatted help text.
+ # See the README.txt distributed with Optik for licensing terms.
+
+ import os
+-import textwrap
++from . import textwrap
+ from optik.option import NO_DEFAULT
+ from optik.errors import gettext as _
+
+@@ -110,10 +110,10 @@ class HelpFormatter:
+ self.level -= 1
+
+ def format_usage(self, usage):
+- raise NotImplementedError, "subclasses must implement"
++ raise NotImplementedError("subclasses must implement")
+
+ def format_heading(self, heading):
+- raise NotImplementedError, "subclasses must implement"
++ raise NotImplementedError("subclasses must implement")
+
+ def _format_text(self, text):
+ """
+--- lib/option.py.orig 2006-06-11 16:22:02 UTC
++++ lib/option.py
+@@ -14,14 +14,8 @@ __revision__ = "$Id: option.py 522 2006-06-11 16:22:03
+
+ __all__ = ['Option']
+
+-# Do the right thing with boolean values for all known Python versions.
+-try:
+- True, False
+-except NameError:
+- (True, False) = (1, 0)
++_idmax = 2 * sys.maxsize + 1
+
+-_idmax = 2L * sys.maxint + 1
+-
+ def _repr(self):
+ return "<%s at 0x%x: %s>" % (self.__class__.__name__,
+ id(self) & _idmax,
+@@ -44,7 +38,7 @@ def _parse_int(val):
+ return _parse_num(val, int)
+
+ def _parse_long(val):
+- return _parse_num(val, long)
++ return _parse_num(val, int)
+
+ _builtin_cvt = { "int" : (_parse_int, _("integer")),
+ "long" : (_parse_long, _("long integer")),
+@@ -211,7 +205,7 @@ class Option:
+ # Filter out None because early versions of Optik had exactly
+ # one short option and one long option, either of which
+ # could be None.
+- opts = filter(None, opts)
++ opts = [_f for _f in opts if _f]
+ if not opts:
+ raise TypeError("at least one option string must be supplied")
+ return opts
+@@ -239,7 +233,7 @@ class Option:
+
+ def _set_attrs(self, attrs):
+ for attr in self.ATTRS:
+- if attrs.has_key(attr):
++ if attr in attrs:
+ setattr(self, attr, attrs[attr])
+ del attrs[attr]
+ else:
+@@ -248,7 +242,7 @@ class Option:
+ else:
+ setattr(self, attr, None)
+ if attrs:
+- attrs = attrs.keys()
++ attrs = list(attrs.keys())
+ attrs.sort()
+ raise OptionError(
+ "invalid keyword arguments: %s" % ", ".join(attrs),
+@@ -278,8 +272,8 @@ class Option:
+ # complicated check of __builtin__ is only necessary for
+ # Python 2.1 and earlier, and is short-circuited by the
+ # first check on modern Pythons.)
+- import __builtin__
+- if ( type(self.type) is types.TypeType or
++ import builtins
++ if ( type(self.type) is type or
+ (hasattr(self.type, "__name__") and
+ getattr(__builtin__, self.type.__name__, None) is self.type) ):
+ self.type = self.type.__name__
+@@ -298,7 +292,7 @@ class Option:
+ if self.choices is None:
+ raise OptionError(
+ "must supply a list of choices for type 'choice'", self)
+- elif type(self.choices) not in (types.TupleType, types.ListType):
++ elif type(self.choices) not in (tuple, list):
+ raise OptionError(
+ "choices must be a list of strings ('%s' supplied)"
+ % str(type(self.choices)).split("'")[1], self)
+@@ -342,12 +336,12 @@ class Option:
+ raise OptionError(
+ "callback not callable: %r" % self.callback, self)
+ if (self.callback_args is not None and
+- type(self.callback_args) is not types.TupleType):
++ type(self.callback_args) is not tuple):
+ raise OptionError(
+ "callback_args, if supplied, must be a tuple: not %r"
+ % self.callback_args, self)
+ if (self.callback_kwargs is not None and
+- type(self.callback_kwargs) is not types.DictType):
++ type(self.callback_kwargs) is not dict):
+ raise OptionError(
+ "callback_kwargs, if supplied, must be a dict: not %r"
+ % self.callback_kwargs, self)
+@@ -444,7 +438,7 @@ class Option:
+ parser.print_version()
+ parser.exit()
+ else:
+- raise RuntimeError, "unknown action %r" % self.action
++ raise RuntimeError("unknown action %r" % self.action)
+
+ return 1
+
+--- lib/option_parser.py.orig 2006-07-23 15:21:30 UTC
++++ lib/option_parser.py
+@@ -23,20 +23,14 @@ __all__ = ['SUPPRESS_HELP', 'SUPPRESS_USAGE',
+ SUPPRESS_HELP = "SUPPRESS"+"HELP"
+ SUPPRESS_USAGE = "SUPPRESS"+"USAGE"
+
+-# For compatibility with Python 2.2
+-try:
+- True, False
+-except NameError:
+- (True, False) = (1, 0)
+-
+ def isbasestring(x):
+- return isinstance(x, types.StringType) or isinstance(x, types.UnicodeType)
++ return isinstance(x, bytes) or isinstance(x, str)
+
+ class Values:
+
+ def __init__(self, defaults=None):
+ if defaults:
+- for (attr, val) in defaults.items():
++ for (attr, val) in list(defaults.items()):
+ setattr(self, attr, val)
+
+ def __str__(self):
+@@ -47,7 +41,7 @@ class Values:
+ def __cmp__(self, other):
+ if isinstance(other, Values):
+ return cmp(self.__dict__, other.__dict__)
+- elif isinstance(other, types.DictType):
++ elif isinstance(other, dict):
+ return cmp(self.__dict__, other)
+ else:
+ return -1
+@@ -60,7 +54,7 @@ class Values:
+ are silently ignored.
+ """
+ for attr in dir(self):
+- if dict.has_key(attr):
++ if attr in dict:
+ dval = dict[attr]
+ if dval is not None:
+ setattr(self, attr, dval)
+@@ -79,7 +73,7 @@ class Values:
+ elif mode == "loose":
+ self._update_loose(dict)
+ else:
+- raise ValueError, "invalid update mode: %r" % mode
++ raise ValueError("invalid update mode: %r" % mode)
+
+ def read_module(self, modname, mode="careful"):
+ __import__(modname)
+@@ -88,7 +82,7 @@ class Values:
+
+ def read_file(self, filename, mode="careful"):
+ vars = {}
+- execfile(filename, vars)
++ exec(compile(open(filename, "rb").read(), filename, 'exec'), vars)
+ self._update(vars, mode)
+
+ def ensure_value(self, attr, value):
+@@ -158,7 +152,7 @@ class OptionContainer:
+
+ def set_conflict_handler(self, handler):
+ if handler not in ("error", "resolve"):
+- raise ValueError, "invalid conflict_resolution value %r" % handler
++ raise ValueError("invalid conflict_resolution value %r" % handler)
+ self.conflict_handler = handler
+
+ def set_description(self, description):
+@@ -180,10 +174,10 @@ class OptionContainer:
+ def _check_conflict(self, option):
+ conflict_opts = []
+ for opt in option._short_opts:
+- if self._short_opt.has_key(opt):
++ if opt in self._short_opt:
+ conflict_opts.append((opt, self._short_opt[opt]))
+ for opt in option._long_opts:
+- if self._long_opt.has_key(opt):
++ if opt in self._long_opt:
+ conflict_opts.append((opt, self._long_opt[opt]))
+
+ if conflict_opts:
+@@ -208,14 +202,14 @@ class OptionContainer:
+ """add_option(Option)
+ add_option(opt_str, ..., kwarg=val, ...)
+ """
+- if type(args[0]) is types.StringType:
++ if type(args[0]) is bytes:
+ option = self.option_class(*args, **kwargs)
+ elif len(args) == 1 and not kwargs:
+ option = args[0]
+ if not isinstance(option, Option):
+- raise TypeError, "not an Option instance: %r" % option
++ raise TypeError("not an Option instance: %r" % option)
+ else:
+- raise TypeError, "invalid arguments"
++ raise TypeError("invalid arguments")
+
+ self._check_conflict(option)
+
+@@ -229,7 +223,7 @@ class OptionContainer:
+ if option.dest is not None: # option has a dest, we need a default
+ if option.default is not NO_DEFAULT:
+ self.defaults[option.dest] = option.default
+- elif not self.defaults.has_key(option.dest):
++ elif option.dest not in self.defaults:
+ self.defaults[option.dest] = None
+
+ return option
+@@ -245,8 +239,8 @@ class OptionContainer:
+ self._long_opt.get(opt_str))
+
+ def has_option(self, opt_str):
+- return (self._short_opt.has_key(opt_str) or
+- self._long_opt.has_key(opt_str))
++ return (opt_str in self._short_opt or
++ opt_str in self._long_opt)
+
+ def remove_option(self, opt_str):
+ option = self._short_opt.get(opt_str)
+@@ -519,16 +513,16 @@ class OptionParser (OptionContainer):
+
+ def add_option_group(self, *args, **kwargs):
+ # XXX lots of overlap with OptionContainer.add_option()
+- if type(args[0]) is types.StringType:
++ if type(args[0]) is bytes:
+ group = OptionGroup(self, *args, **kwargs)
+ elif len(args) == 1 and not kwargs:
+ group = args[0]
+ if not isinstance(group, OptionGroup):
+- raise TypeError, "not an OptionGroup instance: %r" % group
++ raise TypeError("not an OptionGroup instance: %r" % group)
+ if group.parser is not self:
+- raise ValueError, "invalid OptionGroup (wrong parser)"
++ raise ValueError("invalid OptionGroup (wrong parser)")
+ else:
+- raise TypeError, "invalid arguments"
++ raise TypeError("invalid arguments")
+
+ self.option_groups.append(group)
+ return group
+@@ -582,7 +576,7 @@ class OptionParser (OptionContainer):
+
+ try:
+ stop = self._process_args(largs, rargs, values)
+- except (BadOptionError, OptionValueError), err:
++ except (BadOptionError, OptionValueError) as err:
+ self.error(str(err))
+
+ args = largs + rargs
+@@ -784,7 +778,7 @@ class OptionParser (OptionContainer):
+ or not defined.
+ """
+ if self.usage:
+- print >>file, self.get_usage()
++ print(self.get_usage(), file=file)
+
+ def get_version(self):
+ if self.version:
+@@ -801,7 +795,7 @@ class OptionParser (OptionContainer):
+ name. Does nothing if self.version is empty or undefined.
+ """
+ if self.version:
+- print >>file, self.get_version()
++ print(self.get_version(), file=file)
+
+ def format_option_help(self, formatter=None):
+ if formatter is None:
+@@ -864,11 +858,11 @@ def _match_abbrev(s, wordmap):
+ 'words', raise BadOptionError.
+ """
+ # Is there an exact match?
+- if wordmap.has_key(s):
++ if s in wordmap:
+ return s
+ else:
+ # Isolate all words with s as a prefix.
+- possibilities = [word for word in wordmap.keys()
++ possibilities = [word for word in list(wordmap.keys())
+ if word.startswith(s)]
+ # No exact match, so there had better be just one possibility.
+ if len(possibilities) == 1:
+--- lib/textwrap.py.orig 2006-04-20 01:06:35 UTC
++++ lib/textwrap.py
+@@ -10,14 +10,6 @@ __revision__ = "$Id: textwrap.py 39169 2005-07-15 06:5
+ 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
+-# 2.3, e.g. Optik and Docutils).
+-try:
+- True, False
+-except NameError:
+- (True, False) = (1, 0)
+-
+ __all__ = ['TextWrapper', 'wrap', 'fill']
+
+ # Hardcode the recognized whitespace characters to the US-ASCII
+@@ -69,7 +61,7 @@ class TextWrapper:
+ whitespace_trans = string.maketrans(_whitespace, ' ' * len(_whitespace))
+
+ unicode_whitespace_trans = {}
+- uspace = ord(u' ')
++ uspace = ord(' ')
+ for x in map(ord, _whitespace):
+ unicode_whitespace_trans[x] = uspace
+
+@@ -122,9 +114,9 @@ class TextWrapper:
+ if self.expand_tabs:
+ text = text.expandtabs()
+ if self.replace_whitespace:
+- if isinstance(text, types.StringType):
++ if isinstance(text, bytes):
+ text = text.translate(self.whitespace_trans)
+- elif isinstance(text, types.UnicodeType):
++ elif isinstance(text, str):
+ text = text.translate(self.unicode_whitespace_trans)
+ return text
+
+@@ -141,7 +133,7 @@ class TextWrapper:
+ 'use', ' ', 'the', ' ', '-b', ' ', 'option!'
+ """
+ chunks = self.wordsep_re.split(text)
+- chunks = filter(None, chunks)
++ chunks = [_f for _f in chunks if _f]
+ return chunks
+
+ def _fix_sentence_endings(self, chunks):