File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/python3
2
2
3
- import os
4
3
from optparse import OptionParser
4
+ from pathlib import PurePath
5
5
6
6
7
- def basename (opts , names : list [str ]):
8
- for name in names :
7
+ def basename (opts , paths : list [PurePath ]):
8
+ for path in paths :
9
9
print (
10
- os . path .basename ( name .removesuffix (opts .suffix ) ),
10
+ path .name .removesuffix (opts .suffix ),
11
11
end = "\0 " if opts .zero else "\n " ,
12
12
)
13
13
@@ -52,4 +52,4 @@ def basename(opts, names: list[str]):
52
52
else :
53
53
opts .suffix = ""
54
54
55
- basename (opts , args )
55
+ basename (opts , map ( PurePath , args ) )
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/python3
2
2
3
- import os
4
3
from optparse import OptionParser
4
+ from pathlib import PurePath
5
5
6
6
7
- def dirname (opts , names : list [str ]):
8
- for name in names :
9
- print (os . path .dirname ( name ) or "." , end = "\0 " if opts .zero else "\n " )
7
+ def dirname (opts , paths : list [PurePath ]):
8
+ for path in paths :
9
+ print (path .parent , end = "\0 " if opts .zero else "\n " )
10
10
11
11
12
12
if __name__ == "__main__" :
@@ -32,4 +32,4 @@ def dirname(opts, names: list[str]):
32
32
if not args :
33
33
parser .error ("missing operand" )
34
34
35
- dirname (opts , args )
35
+ dirname (opts , map ( PurePath , args ) )
You can’t perform that action at this time.
0 commit comments