Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enum34 compatibility #5

Open
mmilitzer opened this issue Nov 1, 2016 · 1 comment
Open

enum34 compatibility #5

mmilitzer opened this issue Nov 1, 2016 · 1 comment

Comments

@mmilitzer
Copy link

mmilitzer commented Nov 1, 2016

I've installed grizzled-python 1.0.7 in python 2.7 to parse ftp directory listings (net/ftp/parse.py module). It pulls in also 'enum34' as a dependency but the 'Enum'-related code in parse.py looks like it's written against the older 'enum' and not the 'enum34' package. At least when I try to import 'parse_ftp_list_line', python also throws some exceptions.

I think the problem is that the enum34 "functional API" requires the first argument to be the name of the enumeration and the second argument the source of enumeration members as a sequence of names:

https://docs.python.org/3/library/enum.html#functional-api

Here's the patch that I applied, which seems to work for me:

--- ./grizzled/net/ftp/parse.py_orig    2016-11-01 12:10:47.795948217 +0000
+++ ./grizzled/net/ftp/parse.py 2016-11-01 12:19:08.766882529 +0000
@@ -48,6 +48,7 @@
 import time
 import calendar
 from ftplib import error_perm
+from enum import Enum

 # ---------------------------------------------------------------------------
 # Exports
@@ -67,7 +68,7 @@
 MONTHS = ('jan', 'feb', 'mar', 'apr', 'may', 'jun',
           'jul', 'aug', 'sep', 'oct', 'nov', 'dec')

-MTIME_TYPE = Enum('UNKNOWN', 'LOCAL', 'REMOTE_MINUTE', 'REMOTE_DAY')
+MTIME_TYPE = Enum('MTIME_TYPE', ['UNKNOWN', 'LOCAL', 'REMOTE_MINUTE', 'REMOTE_DAY'])
 """
 ``MTIME_TYPE`` identifies how a modification time ought to be interpreted
 (assuming the caller cares).
@@ -78,7 +79,7 @@
     - ``UNKNOWN``: Time's locale is unknown.
 """

-ID_TYPE = Enum('UNKNOWN', 'FULL')
+ID_TYPE = Enum('ID_TYPE', ['UNKNOWN', 'FULL'])
 """
 ``ID_TYPE`` identifies how a file's identifier should be interpreted.

@bmc
Copy link
Owner

bmc commented Nov 1, 2016

Honestly, enum is such a mess in Python that I should just rewrite the code to use constants. In any case, I'll patch a new version shortly. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants