From 223241529a027ab66dc4bdcc839e574de11d407d Mon Sep 17 00:00:00 2001 From: Tushar Gohad Date: Wed, 22 Jul 2015 09:25:56 -0700 Subject: PEP8 fixes Still TODO: test code --- pyeclib/core.py | 78 ++++++++++++++++++---------------- pyeclib/ec_iface.py | 60 ++++++++++++++------------ pyeclib/enum.py | 119 ++++++++++++++++++++++++++++++---------------------- pyeclib/utils.py | 4 +- setup.py | 5 ++- 5 files changed, 149 insertions(+), 117 deletions(-) diff --git a/pyeclib/core.py b/pyeclib/core.py index 2a1f0fb..e4a2d3c 100644 --- a/pyeclib/core.py +++ b/pyeclib/core.py @@ -67,30 +67,35 @@ class ECPyECLibDriver(object): return pyeclib_c.encode(self.handle, data_bytes) def _validate_and_return_fragment_size(self, fragments): - if len(fragments) > 0 and len(fragments[0]) == 0: - return -1 - fragment_len = len(fragments[0]) - - for fragment in fragments[1:]: - if len(fragment) != fragment_len: - return -1 - - return fragment_len - - def decode(self, fragment_payloads, ranges=None, force_metadata_checks=False): - fragment_len = self._validate_and_return_fragment_size(fragment_payloads) + if len(fragments) > 0 and len(fragments[0]) == 0: + return -1 + fragment_len = len(fragments[0]) + for fragment in fragments[1:]: + if len(fragment) != fragment_len: + return -1 + return fragment_len + + def decode(self, fragment_payloads, ranges=None, + force_metadata_checks=False): + fragment_len = self._validate_and_return_fragment_size( + fragment_payloads) if fragment_len < 0: - raise ECDriverError("Invalid fragment payload in ECPyECLibDriver.decode") + raise ECDriverError( + "Invalid fragment payload in ECPyECLibDriver.decode") if len(fragment_payloads) < self.k: - raise ECInsufficientFragments("Not enough fragments given in ECPyECLibDriver.decode") + raise ECInsufficientFragments( + "Not enough fragments given in ECPyECLibDriver.decode") - return pyeclib_c.decode(self.handle, fragment_payloads, fragment_len, ranges, force_metadata_checks) + return pyeclib_c.decode(self.handle, fragment_payloads, fragment_len, + ranges, force_metadata_checks) def reconstruct(self, fragment_payloads, indexes_to_reconstruct): - fragment_len = self._validate_and_return_fragment_size(fragment_payloads) + fragment_len = self._validate_and_return_fragment_size( + fragment_payloads) if fragment_len < 0: - raise ECDriverError("Invalid fragment payload in ECPyECLibDriver.reconstruct") + raise ECDriverError( + "Invalid fragment payload in ECPyECLibDriver.reconstruct") reconstructed_data = [] _fragment_payloads = fragment_payloads[:] @@ -119,17 +124,20 @@ class ECPyECLibDriver(object): """ FIXME - fix this to return a function of HD """ return 1 - def get_metadata(self, fragment, formatted = 0): - fragment_metadata = pyeclib_c.get_metadata(self.handle, fragment, formatted) - return fragment_metadata + def get_metadata(self, fragment, formatted=0): + fragment_metadata = pyeclib_c.get_metadata(self.handle, fragment, + formatted) + return fragment_metadata def verify_stripe_metadata(self, fragment_metadata_list): - success = pyeclib_c.check_metadata(self.handle, fragment_metadata_list) - return success + success = pyeclib_c.check_metadata(self.handle, fragment_metadata_list) + return success def get_segment_info(self, data_len, segment_size): - segment_info = pyeclib_c.get_segment_info(self.handle, data_len, segment_size) - return segment_info + segment_info = pyeclib_c.get_segment_info(self.handle, data_len, + segment_size) + return segment_info + class ECNullDriver(object): @@ -150,7 +158,7 @@ class ECNullDriver(object): def fragments_needed(self, missing_fragment_indexes): pass - def get_metadata(self, fragment, formatted = 0): + def get_metadata(self, fragment, formatted=0): pass def min_parity_fragments_needed(self): @@ -204,22 +212,22 @@ class ECStripingDriver(object): return fragments - def decode(self, fragment_payloads, ranges=None, force_metadata_checks=False): + def decode(self, fragment_payloads, ranges=None, + force_metadata_checks=False): """Convert a k-fragment data stripe into a string :param fragment_payloads: fragments (in order) to convert into a string - :param ranges (unsupported): this driver does not current support range - decode - :param force_metadata_checks (unsupported): this driver does not support - fragment metadata - :returns: a string containing the original data + :param ranges (unsupported): range decode + :param force_metadata_checks (unsupported): verify fragment metadata + :returns: a string containing original data :raises: ECDriverError if there is an error during decoding """ if ranges is not None: - raise ECDriverError( - "Decode does not support range requests in the striping driver.") + raise ECDriverError("Decode does not support range requests in the" + " striping driver.") if force_metadata_checks is not False: raise ECDriverError( - "Decode does not support metadata integrity checks in the striping driver.") + "Decode does not support metadata integrity checks in the " + " striping driver.") if len(fragment_payloads) != self.k: raise ECInsufficientFragments( "Decode requires %d fragments, %d fragments were given" % @@ -260,7 +268,7 @@ class ECStripingDriver(object): def min_parity_fragments_needed(self): pass - def get_metadata(self, fragment, formatted = 0): + def get_metadata(self, fragment, formatted=0): """This driver does not include fragment metadata, so return empty string :param fragment: a fragment diff --git a/pyeclib/ec_iface.py b/pyeclib/ec_iface.py index 4cc9eb6..27c92f7 100644 --- a/pyeclib/ec_iface.py +++ b/pyeclib/ec_iface.py @@ -123,18 +123,18 @@ class ECDriver(object): if key == "k": try: self.k = positive_int_value(value) - except ValueError as e: + except ValueError: raise ECDriverError( "Invalid number of data fragments (k)") elif key == "m": try: self.m = positive_int_value(value) - except ValueError as e: + except ValueError: raise ECDriverError( "Invalid number of data fragments (m)") elif key == "ec_type": if value in ["flat_xor_hd_3", "flat_xor_hd_4"]: - value = "flat_xor_hd" + value = "flat_xor_hd" if PyECLib_EC_Types.has_enum(value): self.ec_type = \ PyECLib_EC_Types.get_by_name(value) @@ -198,7 +198,8 @@ class ECDriver(object): """ return self.ec_lib_reference.encode(data_bytes) - def decode(self, fragment_payloads, ranges=None, force_metadata_checks=False): + def decode(self, fragment_payloads, ranges=None, + force_metadata_checks=False): """ Decode a set of fragments into a buffer that represents the original buffer passed into encode(). @@ -213,7 +214,7 @@ class ECDriver(object): :raises: ECDriverError if there is an error during decoding """ return self.ec_lib_reference.decode(fragment_payloads, ranges, - force_metadata_checks) + force_metadata_checks) def reconstruct(self, available_fragment_payloads, missing_fragment_indexes): @@ -236,7 +237,8 @@ class ECDriver(object): return self.ec_lib_reference.reconstruct( available_fragment_payloads, missing_fragment_indexes) - def fragments_needed(self, reconstruction_indexes, exclude_indexes = []): + def fragments_needed(self, reconstruction_indexes, + exclude_indexes=[]): """ Determine which fragments are needed to reconstruct some subset of missing fragments. @@ -247,18 +249,19 @@ class ECDriver(object): :param exclude_indexes: a list of integers representing the indexes of the fragments to be excluded from the reconstruction - equations. - :returns: a list containing fragment indexes that can be used to + equations. + :returns: a list containing fragment indexes that can be used to reconstruct the missing fragments. :raises: ECDriverError if there is an error during decoding or there are not sufficient fragments to decode """ - return self.ec_lib_reference.fragments_needed(reconstruction_indexes, exclude_indexes) + return self.ec_lib_reference.fragments_needed(reconstruction_indexes, + exclude_indexes) def min_parity_fragments_needed(self): return self.ec_lib_reference.min_parity_fragments_needed() - def get_metadata(self, fragment, formatted = 0): + def get_metadata(self, fragment, formatted=0): """ Get opaque metadata for a fragment. The metadata is opaque to the client, but meaningful to the underlying library. It is used to verify @@ -321,37 +324,38 @@ class ECDriver(object): Get segmentation info for a byterange request, given a data length and segment size. - This will return a map-of-maps that represents a recipe describing + This will return a map-of-maps that represents a recipe describing the segments and ranges within each segment needed to satisfy a range request. Assume a range request is given for an object with segment size 3K and a 1 MB file: - Ranges = (0, 1), (1, 12), (10, 1000), (0, segment_size-1), + Ranges = (0, 1), (1, 12), (10, 1000), (0, segment_size-1), (1, segment_size+1), (segment_size-1, 2*segment_size) This will return a map keyed on the ranges, where there is a recipe given for each range: { - (0, 1): {0: (0, 1)}, - (10, 1000): {0: (10, 1000)}, - (1, 12): {0: (1, 12)}, - (0, 3071): {0: (0, 3071)}, - (3071, 6144): {0: (3071, 3071), 1: (0, 3071), 2: (0, 0)}, + (0, 1): {0: (0, 1)}, + (10, 1000): {0: (10, 1000)}, + (1, 12): {0: (1, 12)}, + (0, 3071): {0: (0, 3071)}, + (3071, 6144): {0: (3071, 3071), 1: (0, 3071), 2: (0, 0)}, (1, 3073): {0: (1, 3071), 1: (0,0)} } """ - segment_info = self.ec_lib_reference.get_segment_info(data_len, segment_size) + segment_info = self.ec_lib_reference.get_segment_info( + data_len, segment_size) segment_size = segment_info['segment_size'] - last_segment_size = segment_info['last_segment_size'] - fragment_size = segment_info['fragment_size'] - last_fragment_size = segment_info['last_fragment_size'] - num_segments = segment_info['num_segments'] + # last_segment_size = segment_info['last_segment_size'] + # fragment_size = segment_info['fragment_size'] + # last_fragment_size = segment_info['last_fragment_size'] + # num_segments = segment_info['num_segments'] sorted_ranges = ranges[:] sorted_ranges.sort(key=lambda obj: obj[0]) @@ -368,15 +372,17 @@ class ECDriver(object): if begin_segment == end_segment: begin_relative_off = begin_off % segment_size end_relative_off = end_off % segment_size - segment_map[begin_segment] = (begin_relative_off, end_relative_off) + segment_map[begin_segment] = (begin_relative_off, + end_relative_off) else: begin_relative_off = begin_off % segment_size end_relative_off = end_off % segment_size - segment_map[begin_segment] = (begin_relative_off, segment_size-1) + segment_map[begin_segment] = (begin_relative_off, + segment_size - 1) - for middle_segment in range(begin_segment+1, end_segment): - segment_map[middle_segment] = (0, segment_size-1) + for middle_segment in range(begin_segment + 1, end_segment): + segment_map[middle_segment] = (0, segment_size - 1) segment_map[end_segment] = (0, end_relative_off) @@ -400,7 +406,7 @@ class ECDriverError(Exception): return self.error_str -## More specific exceptions, mapped to liberasurecode error codes +# More specific exceptions, mapped to liberasurecode error codes # Specified EC backend is not supported by PyECLib/liberasurecode class ECBackendNotSupported(ECDriverError): diff --git a/pyeclib/enum.py b/pyeclib/enum.py index 21ba919..625dea9 100644 --- a/pyeclib/enum.py +++ b/pyeclib/enum.py @@ -50,6 +50,7 @@ except NameError: # in Python 3 it's just str, but was missing in 3.1 basestring = str + class _RouteClassAttributeToGetattr(object): """Route attribute access on a class to __getattr__. @@ -76,8 +77,7 @@ class _RouteClassAttributeToGetattr(object): def _is_descriptor(obj): """Returns True if obj is a descriptor, False otherwise.""" - return ( - hasattr(obj, '__get__') or + return (hasattr(obj, '__get__') or hasattr(obj, '__set__') or hasattr(obj, '__delete__')) @@ -92,7 +92,7 @@ def _is_dunder(name): def _is_sunder(name): """Returns True if a _sunder_ name, False otherwise.""" - return (name[0] == name[-1] == '_' and + return (name[0] == name[-1] == '_' and name[1:2] != '_' and name[-2:-1] != '_' and len(name) > 2) @@ -174,8 +174,8 @@ class EnumMeta(type): classdict[k] = v member_type, first_enum = metacls._get_mixins_(bases) - __new__, save_new, use_args = metacls._find_new_(classdict, member_type, - first_enum) + __new__, save_new, use_args = metacls._find_new_( + classdict, member_type, first_enum) # save enum items into separate mapping so they don't get baked into # the new class members = dict((k, classdict[k]) for k in classdict._member_names) @@ -186,7 +186,8 @@ class EnumMeta(type): __order__ = classdict.get('__order__') if __order__ is None: if pyver < 3.0: - __order__ = [name for (name, value) in sorted(members.items(), key=lambda item: item[1])] + __order__ = [name for (name, value) in + sorted(members.items(), key=lambda item: item[1])] else: __order__ = classdict._member_names else: @@ -203,7 +204,8 @@ class EnumMeta(type): ', '.join(invalid_names), )) # create our new Enum type - enum_class = super(EnumMeta, metacls).__new__(metacls, cls, bases, classdict) + enum_class = super(EnumMeta, metacls).__new__(metacls, cls, bases, + classdict) enum_class._member_names_ = [] # names in random order if OrderedDict is not None: enum_class._member_map_ = OrderedDict() @@ -251,14 +253,13 @@ class EnumMeta(type): enum_class._member_names_.append(member_name) enum_class._member_map_[member_name] = enum_member try: - # This may fail if value is not hashable. We can't add the value - # to the map, and by-value lookups for this value will be + # This may fail if value is not hashable. We can't add the + # value to the map, and by-value lookups for this value will be # linear. enum_class._value2member_map_[value] = enum_member except TypeError: pass - # If a custom type is mixed into the Enum, and it does not know how # to pickle itself, pickle.dumps will succeed but pickle.loads will # fail. Rather than have the error show up later and possibly far @@ -273,17 +274,16 @@ class EnumMeta(type): if '__reduce_ex__' not in classdict: if member_type is not object: methods = ('__getnewargs_ex__', '__getnewargs__', - '__reduce_ex__', '__reduce__') + '__reduce_ex__', '__reduce__') if not any(m in member_type.__dict__ for m in methods): _make_class_unpicklable(enum_class) unpicklable = True - # double check that repr and friends are not the mixin's or various # things break (such as pickle) for name in ('__repr__', '__str__', '__format__', '__reduce_ex__'): class_method = getattr(enum_class, name) - obj_method = getattr(member_type, name, None) + # obj_method = getattr(member_type, name, None) enum_method = getattr(first_enum, name, None) if name not in classdict and class_method is not enum_method: if name == '__reduce_ex__' and unpicklable: @@ -308,8 +308,7 @@ class EnumMeta(type): '__ge__', '__eq__', '__ne__', - '__hash__', - ): + '__hash__',): setattr(enum_class, method, getattr(int, method)) # replace any other __new__ with our own (as long as Enum is not None, @@ -318,7 +317,8 @@ class EnumMeta(type): # if the user defined their own __new__, save it before it gets # clobbered in case they subclass later if save_new: - setattr(enum_class, '__member_new__', enum_class.__dict__['__new__']) + setattr(enum_class, '__member_new__', + enum_class.__dict__['__new__']) setattr(enum_class, '__new__', Enum.__dict__['__new__']) return enum_class @@ -351,7 +351,7 @@ class EnumMeta(type): # (see issue19025). if attr in cls._member_map_: raise AttributeError( - "%s: cannot delete Enum member." % cls.__name__) + "%s: cannot delete Enum member." % cls.__name__) super(EnumMeta, cls).__delattr__(attr) def __dir__(self): @@ -388,10 +388,12 @@ class EnumMeta(type): return cls._member_map_[name] def __iter__(cls): - return (cls._member_map_[name] for name in cls._member_names_) + return (cls._member_map_[name] + for name in cls._member_names_) def __reversed__(cls): - return (cls._member_map_[name] for name in reversed(cls._member_names_)) + return (cls._member_map_[name] + for name in reversed(cls._member_names_)) def __len__(cls): return len(cls._member_names_) @@ -435,8 +437,9 @@ class EnumMeta(type): # special processing needed for names? if isinstance(names, basestring): names = names.replace(',', ' ').split() - if isinstance(names, (tuple, list)) and isinstance(names[0], basestring): - names = [(e, i+1) for (i, e) in enumerate(names)] + if isinstance(names, (tuple, list)) and isinstance(names[0], + basestring): + names = [(e, i + 1) for (i, e) in enumerate(names)] # Here, names is either an iterable of (name, value) or a mapping. for item in names: @@ -475,21 +478,20 @@ class EnumMeta(type): """ if not bases or Enum is None: return object, Enum - # double check that we are not subclassing a class with existing # enumeration members; while we're at it, see if any other data # type has been mixed in so we can use the correct __new__ member_type = first_enum = None for base in bases: - if (base is not Enum and + if (base is not Enum and issubclass(base, Enum) and base._member_names_): raise TypeError("Cannot extend enumerations") # base is now the last base in bases if not issubclass(base, Enum): raise TypeError("new enumerations must be created as " - "`ClassName([mixin_type,] enum_type)`") + "`ClassName([mixin_type,] enum_type)`") # get correct mix-in type (either mix-in type of Enum subclass, or # first base if last base is Enum) @@ -522,8 +524,8 @@ class EnumMeta(type): """ # now find the correct __new__, checking to see of one was defined - # by the user; also check earlier enum classes in case a __new__ was - # saved as __member_new__ + # by the user; also check earlier enum classes in case a __new__ + # was saved as __member_new__ __new__ = classdict.get('__new__', None) if __new__: return None, True, True # __new__, save_new, use_args @@ -546,8 +548,7 @@ class EnumMeta(type): None, N__new__, O__new__, - E__new__, - ]: + E__new__, ]: if method == '__member_new__': classdict['__new__'] = target return None, False, True @@ -561,8 +562,8 @@ class EnumMeta(type): __new__ = object.__new__ # if a non-object.__new__ is used then whatever value/tuple was - # assigned to the enum member name will be passed to __new__ and to the - # new enum member's __init__ + # assigned to the enum member name will be passed to __new__ and + # to the new enum member's __init__ if __new__ is object.__new__: use_args = False else: @@ -580,8 +581,8 @@ class EnumMeta(type): """ # now find the correct __new__, checking to see of one was defined - # by the user; also check earlier enum classes in case a __new__ was - # saved as __member_new__ + # by the user; also check earlier enum classes in case a __new__ + # was saved as __member_new__ __new__ = classdict.get('__new__', None) # should __new__ be saved as __member_new__ later? @@ -597,8 +598,7 @@ class EnumMeta(type): None, None.__new__, object.__new__, - Enum.__new__, - ): + Enum.__new__, ): __new__ = target break if __new__ is not None: @@ -607,8 +607,8 @@ class EnumMeta(type): __new__ = object.__new__ # if a non-object.__new__ is used then whatever value/tuple was - # assigned to the enum member name will be passed to __new__ and to the - # new enum member's __init__ + # assigned to the enum member name will be passed to __new__ and + # to the new enum member's __init__ if __new__ is object.__new__: use_args = False else: @@ -624,7 +624,9 @@ class EnumMeta(type): # create the class. ######################################################## temp_enum_dict = {} -temp_enum_dict['__doc__'] = "Generic enumeration.\n\n Derive from this class to define new enumerations.\n\n" +temp_enum_dict['__doc__'] = "Generic enumeration.\n\n "\ + "Derive from this class to define new enumerations.\n\n" + def __new__(cls, value): # all enum instances are actually created during class construction @@ -633,7 +635,7 @@ def __new__(cls, value): if type(value) is cls: # For lookups like Color(Color.red) value = value.value - #return value + # return value # by-value search for a matching enum member # see if it's in the reverse mapping (for hashable values) try: @@ -648,23 +650,28 @@ def __new__(cls, value): temp_enum_dict['__new__'] = __new__ del __new__ + def __repr__(self): return "<%s.%s: %r>" % ( - self.__class__.__name__, self._name_, self._value_) + self.__class__.__name__, self._name_, self._value_) temp_enum_dict['__repr__'] = __repr__ del __repr__ + def __str__(self): return "%s.%s" % (self.__class__.__name__, self._name_) temp_enum_dict['__str__'] = __str__ del __str__ + def __dir__(self): added_behavior = [m for m in self.__class__.__dict__ if m[0] != '_'] - return (['__class__', '__doc__', '__module__', 'name', 'value'] + added_behavior) + return (['__class__', '__doc__', '__module__', 'name', 'value'] + + added_behavior) temp_enum_dict['__dir__'] = __dir__ del __dir__ + def __format__(self, format_spec): # mixed-in Enums should use the mixed-in type's __format__, otherwise # we can get strange results with the Enum name showing up instead of @@ -694,32 +701,37 @@ if pyver < 2.6: return 0 return -1 return NotImplemented - raise TypeError("unorderable types: %s() and %s()" % (self.__class__.__name__, other.__class__.__name__)) + raise TypeError("unorderable types: %s() and %s()" % + (self.__class__.__name__, other.__class__.__name__)) temp_enum_dict['__cmp__'] = __cmp__ del __cmp__ else: def __le__(self, other): - raise TypeError("unorderable types: %s() <= %s()" % (self.__class__.__name__, other.__class__.__name__)) + raise TypeError("unorderable types: %s() <= %s()" % + (self.__class__.__name__, other.__class__.__name__)) temp_enum_dict['__le__'] = __le__ del __le__ def __lt__(self, other): - raise TypeError("unorderable types: %s() < %s()" % (self.__class__.__name__, other.__class__.__name__)) + raise TypeError("unorderable types: %s() < %s()" % + (self.__class__.__name__, other.__class__.__name__)) temp_enum_dict['__lt__'] = __lt__ del __lt__ def __ge__(self, other): - raise TypeError("unorderable types: %s() >= %s()" % (self.__class__.__name__, other.__class__.__name__)) + raise TypeError("unorderable types: %s() >= %s()" % + (self.__class__.__name__, other.__class__.__name__)) temp_enum_dict['__ge__'] = __ge__ del __ge__ def __gt__(self, other): - raise TypeError("unorderable types: %s() > %s()" % (self.__class__.__name__, other.__class__.__name__)) + raise TypeError("unorderable types: %s() > %s()" % + (self.__class__.__name__, other.__class__.__name__)) temp_enum_dict['__gt__'] = __gt__ del __gt__ - + def __eq__(self, other): if type(other) is self.__class__: @@ -728,6 +740,7 @@ def __eq__(self, other): temp_enum_dict['__eq__'] = __eq__ del __eq__ + def __ne__(self, other): if type(other) is self.__class__: return self is not other @@ -735,11 +748,13 @@ def __ne__(self, other): temp_enum_dict['__ne__'] = __ne__ del __ne__ + def __hash__(self): return hash(self._name_) temp_enum_dict['__hash__'] = __hash__ del __hash__ + def __reduce_ex__(self, proto): return self.__class__, (self._value_, ) temp_enum_dict['__reduce_ex__'] = __reduce_ex__ @@ -752,12 +767,14 @@ del __reduce_ex__ # members are not set directly on the enum class -- __getattr__ is # used to look them up. + @_RouteClassAttributeToGetattr def name(self): return self._name_ temp_enum_dict['name'] = name del name + @_RouteClassAttributeToGetattr def value(self): return self._value_ @@ -770,21 +787,21 @@ del temp_enum_dict # Enum has now been created ########################### + class IntEnum(int, Enum): """Enum where members are also (and must be) ints""" def unique(enumeration): - """Class decorator that ensures only unique members exist in an enumeration.""" + """Class decorator that ensures only unique members exist + in an enumeration.""" duplicates = [] for name, member in enumeration.__members__.items(): if name != member.name: duplicates.append((name, member.name)) if duplicates: duplicate_names = ', '.join( - ["%s -> %s" % (alias, name) for (alias, name) in duplicates] - ) + ["%s -> %s" % (alias, name) for (alias, name) in duplicates]) raise ValueError('duplicate names found in %r: %s' % - (enumeration, duplicate_names) - ) + (enumeration, duplicate_names)) return enumeration diff --git a/pyeclib/utils.py b/pyeclib/utils.py index 74c3933..3b7e535 100644 --- a/pyeclib/utils.py +++ b/pyeclib/utils.py @@ -50,7 +50,7 @@ def import_class(import_str): try: __import__(mod_str) return getattr(sys.modules[mod_str], class_str) - except (ValueError, AttributeError) as e: + except (ValueError, AttributeError): raise ImportError('Class %s cannot be found (%)' % (class_str, traceback.format_exception(*sys.exc_info()))) @@ -68,7 +68,7 @@ def create_instance(import_str, *args, **kwargs): """ try: object_class = import_class(import_str) - except Exception as e: + except Exception: raise instance = object_class(*args, **kwargs) diff --git a/setup.py b/setup.py index a843758..4db57bd 100644 --- a/setup.py +++ b/setup.py @@ -50,6 +50,7 @@ default_library_paths = [default_python_libdir, ('%s/usr/local/lib' % _exec_prefix), '/lib', '/usr/lib', '/usr/local/lib'] + # utility routine def _read_file_as_str(name): with open(name, "rt") as f: @@ -115,8 +116,8 @@ class install(_install): if value is not None: opts[optname] = os.path.abspath(value) - prefix = opts['exec_prefix'] - root = opts['root'] + # prefix = opts['exec_prefix'] + # root = opts['root'] installroot = install_lib.install_dir -- cgit v1.2.1