Mercurial > public > mercurial-scm > hg
comparison mercurial/templatefilters.py @ 35539:d1aae6d4efc5 stable
templatefilters: fix doc of basename()
os.path.basename() does NOT strip trailing slashes.
> Note that the result of this function is different from the Unix basename
> program; where basename for '/foo/bar/' returns 'bar', the basename()
> function returns an empty string ('').
https://docs.python.org/2.7/library/os.path.html#os.path.basename
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 07 Jan 2018 12:07:29 +0900 |
parents | 4fdc4adbc838 |
children | 6d65cef5b038 |
comparison
equal
deleted
inserted
replaced
35538:f39cf992216f | 35539:d1aae6d4efc5 |
---|---|
88 return '%s ago' % fmt(t, n, a) | 88 return '%s ago' % fmt(t, n, a) |
89 | 89 |
90 @templatefilter('basename') | 90 @templatefilter('basename') |
91 def basename(path): | 91 def basename(path): |
92 """Any text. Treats the text as a path, and returns the last | 92 """Any text. Treats the text as a path, and returns the last |
93 component of the path after splitting by the path separator | 93 component of the path after splitting by the path separator. |
94 (ignoring trailing separators). For example, "foo/bar/baz" becomes | 94 For example, "foo/bar/baz" becomes "baz" and "foo/bar//" becomes "". |
95 "baz" and "foo/bar//" becomes "bar". | |
96 """ | 95 """ |
97 return os.path.basename(path) | 96 return os.path.basename(path) |
98 | 97 |
99 @templatefilter('count') | 98 @templatefilter('count') |
100 def count(i): | 99 def count(i): |