aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules/fs.py
diff options
context:
space:
mode:
authorMichael Hirsch, Ph.D <scivision@users.noreply.github.com>2019-12-18 23:17:06 -0500
committerXavier Claessens <xclaesse@gmail.com>2019-12-19 08:51:31 -0500
commitfb121f62548bf6d18778d26dd917ae00e1d2c6ef (patch)
tree30d70f65f732386ee0a618f649fb0d4daed32b6d /mesonbuild/modules/fs.py
parent9e219427803c68a24fcc6afa1fb3bbe8a5e4800d (diff)
downloadmeson-fb121f62548bf6d18778d26dd917ae00e1d2c6ef.zip
meson-fb121f62548bf6d18778d26dd917ae00e1d2c6ef.tar.gz
meson-fb121f62548bf6d18778d26dd917ae00e1d2c6ef.tar.bz2
fs: rename samefile => is_samepath
is_samepath better reflects the nature of this function--that files and directories can be compared. Also, instead of raising exceptions, simply return False when one or both .is_samepath(path1, path1) don't exist. This is more intuitive behavior and avoids having an extra if fs.exist() to go with every fs.is_samepath()
Diffstat (limited to 'mesonbuild/modules/fs.py')
-rw-r--r--mesonbuild/modules/fs.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/mesonbuild/modules/fs.py b/mesonbuild/modules/fs.py
index 3307cab..7340fb7 100644
--- a/mesonbuild/modules/fs.py
+++ b/mesonbuild/modules/fs.py
@@ -95,19 +95,19 @@ class FSModule(ExtensionModule):
@stringArgs
@noKwargs
- def samefile(self, state: 'ModuleState', args: typing.Sequence[str], kwargs: dict) -> ModuleReturnValue:
+ def is_samepath(self, state: 'ModuleState', args: typing.Sequence[str], kwargs: dict) -> ModuleReturnValue:
if len(args) != 2:
- raise MesonException('method takes exactly two arguments.')
+ raise MesonException('fs.is_samepath takes exactly two arguments.')
file1 = self._resolve_dir(state, args[0])
file2 = self._resolve_dir(state, args[1])
if not file1.exists():
- raise MesonException('{} is not a file, symlink or directory and therefore cannot be compared'.format(file1))
+ return ModuleReturnValue(False, [])
if not file2.exists():
- raise MesonException('{} is not a file, symlink or directory and therefore cannot be compared'.format(file2))
+ return ModuleReturnValue(False, [])
try:
return ModuleReturnValue(file1.samefile(file2), [])
except OSError:
- raise MesonException('{} could not be compared to {}'.format(file1, file2))
+ return ModuleReturnValue(False, [])
@stringArgs
@noKwargs