Adding dirs with trailing slashes

A bug prevented users to add conf dirs with trailing slashes.
master
Lertsenem 2015-11-28 13:01:43 +01:00
parent 566cdf5df4
commit 84dc120ee8
1 changed files with 11 additions and 1 deletions

View File

@ -540,7 +540,17 @@ if args.command == "add":
if args.confname:
confname = args.confname
else:
confname = os.path.basename(args.conf)
confname = args.conf
# We need to remove trailing '/' because 'os.path.basename("toto/")'
# returns ''. And that's not cool.
while confname[-1] == "/":
confname = confname[:-1] # Remove trailing slashes
confname = os.path.basename(confname)
# Remove leading dots, so the name under which the conffile is saved is
# not hidden.
while confname[0] == ".":
confname = confname[1:] # Remove leading dots