- commit
- a2c116d3bd9c515ffb3765d4b14f48318c5e9b60
- parent
- c09849ba7d8acba625a85bdbbca6e33fd58d655e
- Author
- Tobias Bengfort <tobias.bengfort@gmx.net>
- Date
- 2015-02-05 17:27
Revert "add to ENDPOINTS instead of overwriting" This reverts commit c09849ba7d8acba625a85bdbbca6e33fd58d655e.
Diffstat
| M | README.rst | 64 | +++++++++++++++++++++++++++++++++---------------------------- |
| M | jsonproxy/__init__.py | 1 | - |
2 files changed, 35 insertions, 30 deletions
diff --git a/README.rst b/README.rst
@@ -16,8 +16,10 @@ implements the third variant. So you can do something like this:: 16 16 17 17 With a configuration like this:: 18 1819 -1 ENDPOINTS['github'] = {20 -1 'host': 'https://api.github.com/users/'-1 19 ENDPOINTS = { -1 20 'github': { -1 21 'host': 'https://api.github.com/users/' -1 22 } 21 23 } 22 24 23 25 @@ -45,21 +47,23 @@ HTML pages, PyJSONProxy can extract information from there:: 45 47 46 48 :: 47 4948 -1 ENDPOINTS['github'] = {49 -1 'host': 'https://github.com/',50 -1 'type': 'scrape_item',51 -1 'fields': {52 -1 'login': '.vcard-username',53 -1 'fullname': '.vcard-fullname',54 -1 'email': '.vcard-details .email',55 -1 'join-date': '.vcard-details .join-date@datetime'-1 50 ENDPOINTS = { -1 51 'github': { -1 52 'host': 'https://github.com/', -1 53 'type': 'scrape_item', -1 54 'fields': { -1 55 'login': '.vcard-username', -1 56 'fullname': '.vcard-fullname', -1 57 'email': '.vcard-details .email', -1 58 'join-date': '.vcard-details .join-date@datetime' -1 59 } -1 60 }, -1 61 'repos': { -1 62 'host': 'https://github.com/', -1 63 'type': 'scrape_list', -1 64 'selector': '.popular-repos a.mini-repo-list-item@href' 56 65 } 57 66 }58 -1 ENDPOINTS['repos'] = {59 -1 'host': 'https://github.com/',60 -1 'type': 'scrape_list',61 -1 'selector': '.popular-repos a.mini-repo-list-item@href'62 -1 }63 67 64 68 There a two options here: ``scrape_item`` and ``scrape_list``. The first 65 69 one will take a list of fields and selectors and return only the first @@ -87,20 +91,22 @@ Some simple documentation is auomatically generated and available under 87 91 endpoint). To provide some input for this documentation, you can add a 88 92 description to both endpoints and fields:: 89 9390 -1 ENDPOINTS['github'] = {91 -1 'host': 'https://github.com/',92 -1 'type': 'scrape_item',93 -1 'doc': 'Access data about GitHub users',94 -1 'fields': {95 -1 'login': '.vcard-username',96 -1 'fullname': '.vcard-fullname',97 -1 'email': '.vcard-details .email'98 -1 'join-date': '.vcard-details .join-date@datetime'99 -1 },100 -1 'fields_doc': {101 -1 'login': 'github username',102 -1 'fullname': 'the user\'s full name',103 -1 'join-date': 'date when the user joined github in ISO-xx format'-1 94 ENDPOINTS = { -1 95 'github': { -1 96 'host': 'https://github.com/', -1 97 'type': 'scrape_item', -1 98 'doc': 'Access data about GitHub users', -1 99 'fields': { -1 100 'login': '.vcard-username', -1 101 'fullname': '.vcard-fullname', -1 102 'email': '.vcard-details .email' -1 103 'join-date': '.vcard-details .join-date@datetime' -1 104 }, -1 105 'fields_doc': { -1 106 'login': 'github username', -1 107 'fullname': 'the user\'s full name', -1 108 'join-date': 'date when the user joined github in ISO-xx format' -1 109 } 104 110 } 105 111 } 106 112
diff --git a/jsonproxy/__init__.py b/jsonproxy/__init__.py
@@ -46,7 +46,6 @@ def main(): 46 46 app = Flask(__name__) 47 47 48 48 # load config49 -1 app.config[ENDPOINTS] = {}50 49 config_files = [ 51 50 os.path.expanduser('~/.config/pyjsonproxy.cfg'), 52 51 os.path.abspath('.pyjsonproxy.cfg'),