~hloeung/mojo/force-destroy-model

« back to all changes in this revision

Viewing changes to mojo/shutil_which.py

  • Committer: mergebot at canonical
  • Author(s): "Stuart Bishop"
  • Date: 2020-04-22 13:04:02 UTC
  • mfrom: (545.1.6 blacken)
  • Revision ID: mergebot@juju-139df4-prod-is-toolbox-0.canonical.com-20200422130402-55dc5d92dj2lx14h
Reformat code with black

Reviewed-on: https://code.launchpad.net/~stub/mojo/blacken/+merge/382726
Reviewed-by: Tom Haddon <tom.haddon@canonical.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
        try:
23
23
            path_repr = path_type.__fspath__(path)
24
24
        except AttributeError:
25
 
            if hasattr(path_type, '__fspath__'):
 
25
            if hasattr(path_type, "__fspath__"):
26
26
                raise
27
27
            else:
28
 
                raise TypeError("expected str, bytes or os.PathLike object, "
29
 
                                "not " + path_type.__name__)
 
28
                raise TypeError("expected str, bytes or os.PathLike object, " "not " + path_type.__name__)
30
29
        if isinstance(path_repr, (str, bytes)):
31
30
            return path_repr
32
31
        else:
33
 
            raise TypeError("expected {}.__fspath__() to return str or bytes, "
34
 
                            "not {}".format(path_type.__name__,
35
 
                                            type(path_repr).__name__))
 
32
            raise TypeError(
 
33
                "expected {}.__fspath__() to return str or bytes, "
 
34
                "not {}".format(path_type.__name__, type(path_repr).__name__)
 
35
            )
36
36
 
37
37
    # Check that a given file can be accessed with the correct mode.
38
38
    # Additionally check that `file` is not a directory, as on Windows
39
39
    # directories pass the os.access check.
40
40
    def _access_check(fn, mode):
41
 
        return (os.path.exists(fn) and os.access(fn, mode) and not os.path.isdir(fn))
 
41
        return os.path.exists(fn) and os.access(fn, mode) and not os.path.isdir(fn)
42
42
 
43
43
    def which(cmd, mode=os.F_OK | os.X_OK, path=None):
44
44
        """Given a command, mode, and a PATH string, return the path which