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

Use json #10

Closed
ospalh opened this issue Oct 28, 2012 · 5 comments
Closed

Use json #10

ospalh opened this issue Oct 28, 2012 · 5 comments

Comments

@ospalh
Copy link

ospalh commented Oct 28, 2012

This one is not an error, but the suggestion of an enhancement.
Instead of writing values into a python file, i would use (simple)json. It's really simple.
You basically say object = json.load(open(json_file_path, 'r')) to get to the values and json.dump(object, open(json_file_path, 'w')) to save them.
An example i used is storing "bad" hash values.
My idea would also be to start without a file and use that to indicate no dictionary selected, like the dict_name='None' you used and use a try: ... json.load(...) to check.

@ospalh
Copy link
Author

ospalh commented Nov 1, 2012

I just thought of another problem with that bit of code:
Afais different profiles can't use different language dictionaries.
Not sure if that is something you should do something about. But maybe you could store information like that somewhere in the collection. Maybe in the DeckConf.

@ospalh
Copy link
Author

ospalh commented Nov 5, 2012

Or you could use a .json file in the profile directory. You get the path there as mw.pm.profileFolder().

@ttempe
Copy link
Owner

ttempe commented Nov 10, 2012

In the back of my mind, I knew I had to improve this one feature, but I hadn't thought about it so thoroughly.

Thanks for your tips. It's a great idea to use Json, and a great idea to differenciate profiles.

@ttempe
Copy link
Owner

ttempe commented Nov 12, 2012

mw.pm.profileFolder didn't work (called too early?) so I put it in the add-on dir.

@ttempe ttempe closed this as completed Nov 12, 2012
@ospalh
Copy link
Author

ospalh commented Nov 12, 2012

mw.pm.profileFolder didn't work (called too early?)

Probably. If you want to do the setup per-profile (which imo would be the Right Thing but with a low priority), you could try something like hooks.addHook("profileLoaded", do_the_setup) with a do_the_setup() function.

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

2 participants