Kozea / Kozea/pygal

Custom css and js. JavaScript script relative paths are not resolved (v. 1.4.6)

Open
#129 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
2.8k
Forks
419
PR merge metrics
No merged PRs in 30d

Description

http://pygal.org/other_customizations/ - Related doc is under "Custom css and js" heading.
**_@**_:/usr/local/lib/python3.4/dist-packages/pygal$ pip freeze | grep pygal
pygal==1.4.6

Custom css works with 'relative paths', e.g. the default paths array
css = ['style.css', 'graph.css']
works as intended. Though these paths are not relative to the pygal directory - it should be as follows:
css = ['css/style.css', 'css/graph.css']

With JavaScript its not working with relative paths at all (works with absolute paths):
File "/usr/local/lib/python3.4/dist-packages/pygal/svg.py", line 108, in add_scripts
with io.open(js, encoding='utf-8') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'js/svg.jquery.js'

I suspect that the relative paths are not resolved before usage, as the error suggests. The error is there because the script I use calls pygal which in turn tries to find the JavaScript files in my script's current working directory.

Thanks,
D.

Contributor guide

Open the contributing guide

Research direction

Start in pygal/svg.py at the add_scripts method around line 108, using the reproduction with relative JavaScript paths as the first check. Verify that relative script paths work independently of the caller's current working directory while absolute paths and the existing custom CSS behavior remain working.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.