Skip to content
This repository has been archived by the owner on Oct 4, 2020. It is now read-only.

Commit

Permalink
Simplify libraw param mapping
Browse files Browse the repository at this point in the history
Tweak error message
  • Loading branch information
SamWhited committed May 25, 2015
1 parent 935c54b commit 3d82cfe
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions rawkit/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _prepare_func(self, func):
def __call__(self, func=None):
self._prepare_func(func)
if func is None:
raise TypeError("option must be a method.")
raise TypeError("option should not be called except as a property")
self.func = func
return self

Expand Down Expand Up @@ -377,17 +377,8 @@ def _map_to_libraw_params(self, params):
:param params: the output params struct to set
:type params: :class:`rawkit.libraw.libraw_output_params_t`
"""
def get_dict_attr(obj, attr):
for obj in [obj] + obj.__class__.mro():
try:
if attr in obj.__dict__:
return obj.__dict__[attr]
except:
pass
raise AttributeError

for slot in self.__slots__:
prop = slot[1:]
opt = get_dict_attr(self, prop)
opt = getattr(Options, prop)
if type(opt) is option and getattr(self, prop) is not None:
opt.write_param(self, params)

0 comments on commit 3d82cfe

Please sign in to comment.