@@ -38,6 +38,7 @@ def parse_path(path, prefix=""):
3838 - `path` : The same as `full`, up to (including) the last separator.
3939 - `dname` : The segment between the last two separators (directory).
4040 - `fname` : The segment after the last separator (filename).
41+ - `basename` : The filename without extension.
4142 - `ext` : The filename extension, containing max 1 dot (included).
4243
4344 Examples
@@ -50,6 +51,7 @@ def parse_path(path, prefix=""):
5051 'ext': '',
5152 'fname': 'file',
5253 'full': '/tmp/foo/file',
54+ 'basename': 'file',
5355 'orig': '/tmp/foo/file',
5456 'path': '/tmp/foo/'}
5557
@@ -60,6 +62,7 @@ def parse_path(path, prefix=""):
6062 'ext': '',
6163 'fname': '',
6264 'full': '/tmp/foo/',
65+ 'basename': '',
6366 'orig': '/tmp/foo/',
6467 'path': '/tmp/foo/'}
6568
@@ -70,6 +73,7 @@ def parse_path(path, prefix=""):
7073 'ext': '.ext',
7174 'fname': 'file.ext',
7275 'full': 'C:/Temp/foo/file.ext',
76+ 'basename': 'file',
7377 'orig': 'C:\\Temp\\foo\\file.ext',
7478 'path': 'C:/Temp/foo/'}
7579 """
@@ -86,7 +90,10 @@ def parse_path(path, prefix=""):
8690 parsed ["path" ] = os .path .dirname (path ) + sep
8791 parsed ["fname" ] = os .path .basename (path )
8892 parsed ["dname" ] = os .path .basename (os .path .dirname (parsed ["path" ]))
89- parsed ["ext" ] = os .path .splitext (parsed ["fname" ])[1 ]
93+ split_ext = os .path .splitext (parsed ["fname" ])
94+ parsed ["ext" ] = split_ext [1 ]
95+ parsed ["basename" ] = split_ext [0 ]
96+
9097 return parsed
9198
9299
0 commit comments