-
Notifications
You must be signed in to change notification settings - Fork 20
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 CLI utilities to Kinto.py #34
Conversation
class DummyImporter(KintoImporter): | ||
collection_permissions = {'read': ["system.Everyone"]} | ||
fields = ('name', 'protocol') | ||
set_all = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this option needs to be more explicit.
class DummyImporter(KintoImporter): | ||
all_default_parameters = True | ||
collection_permissions = {'read': ["system.Everyone"]} | ||
fields = ('name', 'protocol') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
record_fields
then?
c8f8fc9
to
4dc096d
Compare
r? @leplatrem |
8f1a24b
to
6a99d25
Compare
@@ -0,0 +1,34 @@ | |||
#!/usr/bin/env python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of having an example, but I feel that this will get out of date as soon as we start updating the importer. We probably should move this into a test case, and point the users there in the documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: importation is rarely used in the context of importing data
all_default_parameters=None, remote_server=None, | ||
authentication=None, files=None, verbosity=None, | ||
*args, **kwargs): | ||
"""Return an argparse.ArgumentParser pre-configured object.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring should contain some more information about the arguments it expects, and what it does with the extra args/kwargfs.
3d7af1b
to
9f975ce
Compare
@@ -1,24 +1,24 @@ | |||
import unittest2 as unittest | |||
import mock | |||
|
|||
from kinto_client.batch import Batch | |||
from kinto_client.batch import Session |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: as BatchSession
?
I didn't review the tests thoroughly. My general feeling would be a friendly warning: do not forget the simplest use-cases like this one https://gist.github.com/leplatrem/a2d95b660820686eea35 |
6ffc0b9
to
02c082b
Compare
02c082b
to
9c6e2ff
Compare
I think something like that should work: #!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
from kinto_client.importer import KintoImporter
class GuessSignImporter(KintoImporter):
include_all_default_parameters = True
default_remote_server = "https://kinto-leplatrem.herokuapp.com/v1"
default_auth = 'admin:password'
default_files = ["guessign/data/it.json"]
collection_permissions = {'read': ["system.Everyone"]}
record_fields = ('class', 'word', 'class:id', 'magnet',
'category', 'video', 'lang')
delete = False
def get_local_records(self):
results = []
with open(file) as f:
results += json.load(f)
return results
def main(args=None):
importer = GuessSignImporter()
importer.sync()
if __name__ == '__main__': # pragma: nocover
main() |
"""Update out-of-date records.""" | ||
update = True | ||
"""Delete records not present in local-files.""" | ||
delete = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_missing_locally
update_missing_locally
delete_missing_locally
I suppose we can close this then, since #59 is being worked out. |
The final aims is to let people easily create sync between a collection and a local data store (usually built from files)