aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mesonlib.py
diff options
context:
space:
mode:
authorAleksey Filippov <alekseyf@google.com>2018-01-29 00:10:43 +0000
committerJussi Pakkanen <jpakkane@gmail.com>2018-01-30 07:08:22 +1100
commit2cf85ae16f79b5edcbfa34d57b477c984c79e7a5 (patch)
treef0c533465924188dec1a95926ae48b4c63c00309 /mesonbuild/mesonlib.py
parent4e5ad57161a475dfab1c1a4edde075b2620b9f75 (diff)
downloadmeson-2cf85ae16f79b5edcbfa34d57b477c984c79e7a5.zip
meson-2cf85ae16f79b5edcbfa34d57b477c984c79e7a5.tar.gz
meson-2cf85ae16f79b5edcbfa34d57b477c984c79e7a5.tar.bz2
Use os.path: basename() and dirname() instead of split()
According to Python documentation[1] dirname and basename are defined as follows: os.path.dirname() = os.path.split()[0] os.path.basename() = os.path.split()[1] For the purpose of better readability split() is replaced by appropriate function if only one part of returned tuple is used. [1]: https://docs.python.org/3/library/os.path.html#os.path.split
Diffstat (limited to 'mesonbuild/mesonlib.py')
-rw-r--r--mesonbuild/mesonlib.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index f7e18d0..a90cb6e 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -857,7 +857,7 @@ def get_filenames_templates_dict(inputs, outputs):
values['@INPUT{}@'.format(ii)] = vv
if len(inputs) == 1:
# Just one value, substitute @PLAINNAME@ and @BASENAME@
- values['@PLAINNAME@'] = plain = os.path.split(inputs[0])[1]
+ values['@PLAINNAME@'] = plain = os.path.basename(inputs[0])
values['@BASENAME@'] = os.path.splitext(plain)[0]
if outputs:
# Gather values derived from the outputs, similar to above.
@@ -865,7 +865,7 @@ def get_filenames_templates_dict(inputs, outputs):
for (ii, vv) in enumerate(outputs):
values['@OUTPUT{}@'.format(ii)] = vv
# Outdir should be the same for all outputs
- values['@OUTDIR@'] = os.path.split(outputs[0])[0]
+ values['@OUTDIR@'] = os.path.dirname(outputs[0])
# Many external programs fail on empty arguments.
if values['@OUTDIR@'] == '':
values['@OUTDIR@'] = '.'
@@ -895,7 +895,7 @@ def detect_subprojects(spdir_name, current_dir='', result=None):
if not os.path.exists(spdir):
return result
for trial in glob(os.path.join(spdir, '*')):
- basename = os.path.split(trial)[1]
+ basename = os.path.basename(trial)
if trial == 'packagecache':
continue
append_this = True