Skip to content

Commit

Permalink
fix(issue): issue #12
Browse files Browse the repository at this point in the history
  • Loading branch information
matfax committed Oct 20, 2019
1 parent dd9cf21 commit 8234c09
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
17 changes: 12 additions & 5 deletions mutapath/decorator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"""
The decorators convert all returning types to mutapath.Path, or mutapath.MutaPath instances, respectively.
The following types are covered:
* Internal routines returning non-iterable types in mutapath
* All types returned from routines and properties from pathlib
* All types returned from routines and properties from path
"""
import functools
import inspect
import pathlib
Expand Down Expand Up @@ -35,7 +42,7 @@ def __is_def(member):

def __path_converter(const: Callable):
def convert_path(result):
if isinstance(result, path.Path) or isinstance(result, pathlib.PurePath):
if isinstance(result, (path.Path, pathlib.PurePath)):
return const(result)
return result

Expand Down Expand Up @@ -113,13 +120,13 @@ def mutation_decorator(self, *args, **kwargs):
if isinstance(result, path.Path):
self._contained = result
return self
elif isinstance(result, mutapath.Path):
if isinstance(result, mutapath.Path):
self._contained = result._contained
return self
return result
else:
result = orig_func(self, *args, **kwargs)
return cls(result)

result = orig_func(self, *args, **kwargs)
return cls(result)

return mutation_decorator

Expand Down
4 changes: 0 additions & 4 deletions mutapath/lock_dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@ class DummyFileLock(BaseFileLock):

def release(self, force=False):
"""Doing nothing"""
pass

def acquire(self, timeout=None, poll_intervall=0.05):
"""Doing nothing"""
pass

def _acquire(self):
"""Doing nothing"""
pass

def _release(self):
"""Doing nothing"""
pass

0 comments on commit 8234c09

Please sign in to comment.