mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Convert '.' and '..' to the less magical os.curdir and os.pardir
While I'm cleaning up path manipulation, I might as well make things more semantic.
This commit is contained in:
parent
a5c1fdac58
commit
b59da89e80
10 changed files with 19 additions and 16 deletions
|
|
@ -306,9 +306,9 @@ def get_relative_path(path):
|
|||
"""Return the relative path from the given path to the root path."""
|
||||
nslashes = path.count('/')
|
||||
if nslashes == 0:
|
||||
return '.'
|
||||
return os.curdir
|
||||
else:
|
||||
return '/'.join(['..'] * nslashes)
|
||||
return '/'.join([os.pardir] * nslashes)
|
||||
|
||||
|
||||
def truncate_html_words(s, num, end_text='...'):
|
||||
|
|
@ -429,7 +429,7 @@ def files_changed(path, extensions, ignores=[]):
|
|||
def file_times(path):
|
||||
"""Return the last time files have been modified"""
|
||||
for root, dirs, files in os.walk(path):
|
||||
dirs[:] = [x for x in dirs if x[0] != '.']
|
||||
dirs[:] = [x for x in dirs if x[0] != os.curdir]
|
||||
for f in files:
|
||||
if any(f.endswith(ext) for ext in extensions) \
|
||||
and not any(fnmatch.fnmatch(f, ignore)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue