Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixing #2109: path bug in get_asset_path and wrong documentation.
  • Loading branch information
felixfontein committed Sep 22, 2015
1 parent e051a1d commit f173fca
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions nikola/utils.py
Expand Up @@ -986,9 +986,12 @@ def get_asset_path(path, themes, files_folders={'files': ''}, _themes_dir='theme
>>> print(get_asset_path('nikola.py', ['bootstrap3', 'base'], {'nikola': ''}))
/.../nikola/nikola.py
>>> print(get_asset_path('nikola/nikola.py', ['bootstrap3', 'base'], {'nikola':'nikola'}))
>>> print(get_asset_path('nikola.py', ['bootstrap3', 'base'], {'nikola': 'nikola'}))
None
>>> print(get_asset_path('nikola/nikola.py', ['bootstrap3', 'base'], {'nikola': 'nikola'}))
/.../nikola/nikola.py
"""
for theme_name in themes:
candidate = os.path.join(
Expand All @@ -998,9 +1001,11 @@ def get_asset_path(path, themes, files_folders={'files': ''}, _themes_dir='theme
if os.path.isfile(candidate):
return candidate
for src, rel_dst in files_folders.items():
candidate = os.path.abspath(os.path.join(src, path))
if os.path.isfile(candidate):
return candidate
relpath = os.path.relpath(path, rel_dst)
if not relpath.startswith('..' + os.path.sep):
candidate = os.path.abspath(os.path.join(src, relpath))
if os.path.isfile(candidate):
return candidate

if output_dir:
candidate = os.path.join(output_dir, path)
Expand Down

0 comments on commit f173fca

Please sign in to comment.