From a44d74d75294e358e501cc83fd35e6a5e50ebf0b Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 12 Jan 2011 13:43:22 -0800 Subject: [PATCH] python: Use os.path.basename instead of open-coding it. Reported-by: Justin Pettit --- build-aux/check-structs | 6 ++---- python/ovs/util.py | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/build-aux/check-structs b/build-aux/check-structs index f582e2bd..536045fe 100755 --- a/build-aux/check-structs +++ b/build-aux/check-structs @@ -1,5 +1,6 @@ #! /usr/bin/python +import os.path import sys import re @@ -193,10 +194,7 @@ def checkStructs(): sys.exit(1) if '--help' in sys.argv: - argv0 = sys.argv[0] - slash = argv0.rfind('/') - if slash: - argv0 = argv0[slash + 1:] + argv0 = os.path.basename(sys.argv[0]) print '''\ %(argv0)s, for checking struct and struct member alignment usage: %(argv0)s HEADER [HEADER]... diff --git a/python/ovs/util.py b/python/ovs/util.py index d4460f39..aa4b9bc3 100644 --- a/python/ovs/util.py +++ b/python/ovs/util.py @@ -1,4 +1,4 @@ -# Copyright (c) 2010 Nicira Networks +# Copyright (c) 2010, 2011 Nicira Networks # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,10 +13,10 @@ # limitations under the License. import os +import os.path import sys -_argv0 = sys.argv[0] -PROGRAM_NAME = _argv0[_argv0.rfind('/') + 1:] +PROGRAM_NAME = os.path.basename(sys.argv[0]) def abs_file_name(dir, file_name): """If 'file_name' starts with '/', returns a copy of 'file_name'. -- 2.30.2