diff options
author | Philipp Ittershagen <pit@shgn.de> | 2017-04-03 20:58:30 +0200 |
---|---|---|
committer | Philipp Ittershagen <pit@shgn.de> | 2017-04-03 21:08:59 +0200 |
commit | 64e8f2c7bf781def278332ce665215ba79827297 (patch) | |
tree | cc3d0984f7f166ed895a23ae1e642507bab1eba5 /mesonbuild/mesonlib.py | |
parent | c7f66c3a9e4f69e0bcde8819f15c9d8b972a2f75 (diff) | |
download | meson-64e8f2c7bf781def278332ce665215ba79827297.zip meson-64e8f2c7bf781def278332ce665215ba79827297.tar.gz meson-64e8f2c7bf781def278332ce665215ba79827297.tar.bz2 |
Refactor duplicate code in File
Increase readability using the File method self.relative_name() to factor out
some of the os.path.join(...) commands.
Diffstat (limited to 'mesonbuild/mesonlib.py')
-rw-r--r-- | mesonbuild/mesonlib.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index c7368d5..cf21182 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -123,14 +123,14 @@ class File: self.fname = fname def __str__(self): - return os.path.join(self.subdir, self.fname) + return self.relative_name() def __repr__(self): ret = '<File: {0}' if not self.is_built: ret += ' (not built)' ret += '>' - return ret.format(os.path.join(self.subdir, self.fname)) + return ret.format(self.relative_name()) @staticmethod def from_source_file(source_root, subdir, fname): @@ -148,15 +148,15 @@ class File: def rel_to_builddir(self, build_to_src): if self.is_built: - return os.path.join(self.subdir, self.fname) + return self.relative_name() else: return os.path.join(build_to_src, self.subdir, self.fname) def absolute_path(self, srcdir, builddir): + absdir = srcdir if self.is_built: - return os.path.join(builddir, self.subdir, self.fname) - else: - return os.path.join(srcdir, self.subdir, self.fname) + absdir = builddir + return os.path.join(absdir, self.relative_name()) def endswith(self, ending): return self.fname.endswith(ending) |