Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
inventory_api_doc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
inventory_api_doc
Commits
213876cf
Commit
213876cf
authored
Oct 04, 2016
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use Alice, Bob and candies in the example
parent
bd7568ab
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
README.md
README.md
+9
-9
No files found.
README.md
View file @
213876cf
...
...
@@ -215,21 +215,21 @@ This method does not check that the provided parameters leads to results that ma
Using one
`getInventoryList`
is usually much more efficient than doing multiple
`getInventory`
/
`getInventoryAssetPrice`
calls.
For example, this code:
```
python
print
"
N1's inventory of R1 is {inventory}
, value is {value}"
.
format
(
inventory
=
getInventory
(
node_uid
=
N1
.
getUid
(),
resource
=
R1
.
getUid
(),
asset_price
=
getInventoryAssetPrice
(
node_uid
=
N1
.
getUid
(),
resource
=
R1
.
getUid
()))
print
"
N2's inventory of R1 is {inventory}
, value is {value}"
.
format
(
inventory
=
getInventory
(
node_uid
=
N2
.
getUid
(),
resource
=
R1
.
getUid
(),
asset_price
=
getInventoryAssetPrice
(
node_uid
=
N2
.
getUid
(),
resource
=
R1
.
getUid
()))
print
"
Alice's has {inventory} candies
, value is {value}"
.
format
(
inventory
=
getInventory
(
node_uid
=
alice
.
getUid
(),
resource
=
candy
.
getUid
(),
asset_price
=
getInventoryAssetPrice
(
node_uid
=
alice
.
getUid
(),
resource_uid
=
candy
.
getUid
()))
print
"
Bob's has {inventory} candies
, value is {value}"
.
format
(
inventory
=
getInventory
(
node_uid
=
bob
.
getUid
(),
resource
=
candy
.
getUid
(),
asset_price
=
getInventoryAssetPrice
(
node_uid
=
bob
.
getUid
(),
resource_uid
=
candy
.
getUid
()))
```
can be written more efficiently with
`getInventoryList`
this way:
```
python
for
brain
in
getInventoryList
(
node_uid
=
(
N1
.
getUid
(),
N2
.
getUid
()),
resource_uid
=
R1
.
getUid
(),
for
brain
in
getInventoryList
(
node_uid
=
(
alice
.
getUid
(),
bob
.
getUid
()),
resource_uid
=
candy
.
getUid
(),
group_by_node
=
True
):
print
"{node}'s inventory of
R1
is {inventory}, value is {value}"
.
format
(
print
"{node}'s inventory of
candy
is {inventory}, value is {value}"
.
format
(
node
=
brain
.
node_title
,
inventory
=
brain
.
total_inventory
,
asset_price
=
brain
.
total_price
)
...
...
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