Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
weboob
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
132
Issues
132
List
Boards
Labels
Milestones
Merge Requests
40
Merge Requests
40
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
weboob
weboob
Commits
aeab3fac
Commit
aeab3fac
authored
Jun 22, 2014
by
Bezleputh
Committed by
Romain Bignon
Jun 23, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[json] handle format_collection
parent
7b5ab26d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
collection.py
weboob/capabilities/collection.py
+14
-0
json.py
weboob/tools/application/formatters/json.py
+3
-0
No files found.
weboob/capabilities/collection.py
View file @
aeab3fac
...
...
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from
weboob.tools.ordereddict
import
OrderedDict
from
.base
import
IBaseCap
,
CapBaseObject
,
UserError
,
StringField
,
Field
...
...
@@ -54,6 +55,19 @@ class BaseCollection(CapBaseObject):
def
path_level
(
self
):
return
len
(
self
.
split_path
)
def
to_dict
(
self
):
def
iter_decorate
(
d
):
for
key
,
value
in
d
:
if
key
==
'id'
and
self
.
backend
is
not
None
:
value
=
u'
%
s@
%
s'
%
(
self
.
basename
,
self
.
backend
)
yield
key
,
value
if
key
==
'split_path'
:
yield
key
,
'/'
.
join
(
value
)
fields_iterator
=
self
.
iter_fields
()
return
OrderedDict
(
iter_decorate
(
fields_iterator
))
class
Collection
(
BaseCollection
):
"""
...
...
weboob/tools/application/formatters/json.py
View file @
aeab3fac
...
...
@@ -57,6 +57,9 @@ class JsonFormatter(IFormatter):
def
format_dict
(
self
,
item
):
self
.
queue
.
append
(
item
)
def
format_collection
(
self
,
collection
,
only
):
self
.
queue
.
append
(
collection
.
to_dict
())
class
JsonLineFormatter
(
IFormatter
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment