Skip to content

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.

3 participants