I have been reviewing the TorCtl package and I will be submitting tickets (usually with patches) for clean-ups, fixes, etc. Before I submit a ticket for removing TorUtil.Enum, I wanted to hear from other devs. There are no users of this class within TorCtl, so Enum is now cruft. Does anyone have a problem with removing Enum? If I do not get negative feedback about this patch, I will submit it later in the week.
The following patch is also attached to this message as a gzipped patch file.
diff --git a/TorUtil.py b/TorUtil.py index 3163d09..1d27144 100644 --- a/TorUtil.py +++ b/TorUtil.py @@ -22,7 +22,7 @@ if sys.version_info < (2, 5): else: from hashlib import sha1
-__all__ = ["Enum", "Enum2", "Callable", "sort_list", "quote", "escape_dots", "unescape_dots", +__all__ = ["Enum2", "Callable", "sort_list", "quote", "escape_dots", "unescape_dots", "BufSock", "secret_to_key", "urandom_rng", "s2k_gen", "s2k_check", "plog", "ListenSocket", "zprob", "logfile", "loglevel", "loglevels"]
@@ -127,16 +127,6 @@ def read_config(filename): loglevel = config.get('TorCtl', 'loglevel')
-class Enum(object): - """ Defines an ordered dense name-to-number 1-1 mapping """ - def __init__(self, start, names): - self.nameOf = {} - idx = start - for name in names: - setattr(self,name,idx) - self.nameOf[idx] = name - idx += 1 - class Enum2(object): """ Defines an ordered sparse name-to-number 1-1 mapping """ def __init__(self, **args): -- 1.7.5.1
I don't have a problem with it being removed (though this is Mike's call). I looked at it a bit for arm's enum implementation... https://gitweb.torproject.org/arm.git/blob/HEAD:/src/util/enum.py
but that's about it. -Damian
On Sat, Jun 18, 2011 at 4:25 PM, Damian Johnson atagar1@gmail.com wrote:
I don't have a problem with it being removed (though this is Mike's call). I looked at it a bit for arm's enum implementation... https://gitweb.torproject.org/arm.git/blob/HEAD:/src/util/enum.py
but that's about it. -Damian
The primary difference between TorUtil.Enum and the arm Enum class: arm has a well-documented, full, useful implementation of an enum class. And, secondarily, I assume it is actually used by code.