Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to use json palette crashes because of file encoding #47

Open
badjano opened this issue Feb 28, 2021 · 0 comments
Open

Trying to use json palette crashes because of file encoding #47

badjano opened this issue Feb 28, 2021 · 0 comments

Comments

@badjano
Copy link

badjano commented Feb 28, 2021

Important notices
Before you add a new report, we ask you kindly to acknowledge the following:

[-] I have read the contributing guide lines at https://github.com/timofurrer/colorful/blob/master/.github/CONTRIBUTING.md
THIS LINK IS BROKEN: https://github.com/timofurrer/colorful/blob/master/.github/CONTRIBUTING.md

[-] I have read and respect the code of conduct at https://github.com/timofurrer/colorful/blob/master/.github/CODE_OF_CONDUCT.md
OK

[-] I have searched the existing issues and I'm convinced that mine is new.
YES, ALTHOUGH SOME MIGHT BE RELATED

Describe the bug
A clear and concise description of what the bug is.

import json

from colorful import Colorful, colors
from colorful.core import COLORNAMES_COLORS_PATH

cf = Colorful(colorpalette=COLORNAMES_COLORS_PATH)  # this is going to crash
colors.parse_json_color_file(COLORNAMES_COLORS_PATH)  # this is the method that is actually crashing

with open(COLORNAMES_COLORS_PATH, encoding="utf8") as f:  # this is how you fix it
    colorpalette = json.load(f)

Environment and Version

  • OS (incl. terminal and shell used): windows, pycharm
  • Python Version: 3.8
  • colorful Version: 0.5.4

To Reproduce
A clear and concise description of steps to reproduce the behavior
you are experiencing.

from colorful import Colorful, colors
from colorful.core import COLORNAMES_COLORS_PATH

cf = Colorful(colorpalette=COLORNAMES_COLORS_PATH)  # this is going to crash
colors.parse_json_color_file(COLORNAMES_COLORS_PATH)  # this is the method that is actually crashing

Expected behavior
A clear and concise description of what you expected to happen.

I think an easier way to extend colors with the json included on this library would be good

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

if you want to I know exactly what to do to fix it so I can make a PR, but I would want to make some changes, like the color name in the json file has spaces and upper cased letters, I would probably change that to camel case, which seems to be the standard for this library

edit: I just realized there is already a sanitize_color_palette that makes the camelcase, sorry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant