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

Add preferences to main app class #99

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

daredoes
Copy link
Collaborator

@daredoes daredoes commented Dec 5, 2018

from https://github.com/laffra/happymac

Provides the methods self.preferences.get and self.preferences.set to all rumps apps, established in the home directory if no directory is provided.

The user can set the preferences to the application folder with the following block in the __init__ function of an app, after a call using super

self.preferences = rumps.Preferences(self._name, self._application_support)

@daredoes daredoes requested a review from jaredks December 5, 2018 04:18
Copy link
Owner

@jaredks jaredks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cool. I like that it's easier to save data but I wonder now in what circumstance do you use,

app = App('Cool App')
with app.open('data.json') as f:
    json.dump({'key': 'value'}, f)

vs.

app = App('Cool App')
app.preferences.set('key', 'value')

Should these concepts not be consolidated?

Also I think we should use serializer rather than hardcode pickle.

self._preferences[key] = value
with open(self._path, "wb") as file:
pickle.dump(self._preferences, file, 2)
print("Set preference %s to %s" % (key, repr(value)))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("Set preference %s to %s" % (key, repr(value)))
_log("Set preference %s to %s" % (key, repr(value)))

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

Successfully merging this pull request may close these issues.

2 participants