Python STEEM 0.4.0 - Massive changes to greatly simplify onboarding - Merged SteemtoolssteemCreated with Sketch.

in #steem8 years ago

In this post we would like to announce a major refactor of python-steem, a library written in Python 3 that allows developers to build full-featured tools on top of the Steem Blockchain such as streemian.com or piston.

Distinct Domain with documentation

Since a couple of days, the major resource for this library can be accessed using our new domain called

pysteem.com

For now, it only holds the current in-code documentation using a rather standard-ish design. We would love to see more python and web-developer join our team of voluntaries to improve the library, documentation and presentation.

Cooperation with steem-tools/steemsports

We are happy to announce a fruitful ongoing cooperation with @furion (the author of steemtools) and are happy to have him integrate his library into python-steem!
The new version of the python-steem has been in part battle tested by powering SteemSports and Streemian.com.

Additional Modules

  • Amount: For the sake of easier handling of Assets on the blockchain

    from steem.amount import Amount
    Amount("1 SBD") + Amount("20 SBD")
    
  • Account: Obtaining and accounts

    from steem.account import Account
    account = Account("xeroc")
    print(account.reputation())
    print(account.balances)
    
  • Block: Easily read data in a Block

    from steem.block import Block
    from pprint import pprint
    pprint(Block(1))
    
  • Blog: Read a users Blog

    from steem.blog import Blog
    print(Blog("xeroc"))
    
  • Witness: Read data about a witness

    from steem.witness import Witness
    Witness("chainsquad.com")
    
  • Blockchain: Blockchain stuff

    from steem.blockchain import Blockchain
    chain = Blockchain()
    print(chain.get_current_block())
    print(chain.info())
    for block in chain.blocks():
        print(block)
        break
    for operations in chain.ops():
        print(operations)
        break
    
  • Transaction Builder: To build your own transactions and sign them

    from steem.transactionbuilder import TransactionBuilder
    from steembase.operations import Vote
    tx = TransactionBuilder()
    tx.appendOps(Vote(
        **{"voter": voter,
           "author": post_author,
           "permlink": post_permlink,
           "weight": int(weight * STEEMIT_1_PERCENT)}  # STEEMIT_1_PERCENT = 100
    ))
    tx.appendSigner("xeroc", "posting")
    tx.sign()
    tx.broadcast()
    

Howto update

pip3 install --upgrade steem

Changelog

[Amount] make None Amounts be zero
[Amount] prevent different assets from adding up
[Block] block class
[Blog] remove dead code
[GOLOS] Modifications + improved assets (#14)
[TransactionBuilder] Make sure we have a wif key to sign a tx
[Transactions] build transactions in it's own class
[account create] prevent new accounts with more than 16 chars
[account,blockchain,setup] removed dateutil dependency
[account/amount] show balances as float or string
[account] allow to obtain more than 200 followers
[account] cleanup - removed methods not catering to most users
[account] converter is now a property that is loaded when needed
[account] fix a bug in curation_stats
[account] fix imports
[account] fix minor issues with keys
[account] fixed bugs induced by Account.history return struct changes
[account] fixed imports
[account] get_blog now in a separated class
[account] improved account virtual operation return object
[account] renamed Account.export method
[account] round precision by argument
[account] simplify check_if_already_voted and rename to has_voted(post)
[amount,converter] removed redundant Converter class from amount.py, re-added caches
[amount] even more powerful
[amount] improve operations
[amount] make amount more powerful
[api.exceptions] Another exception message
[api] add 'end' to block_stream
[api] add missing posting key exception
[api] add timestamp to operations on streams
[api] allow long version for mode
[api] cleanup API module and move things to corresponding modules
[api] improve rpc.stream output structure
[api] new exception
[api] remove legacy graphene overloading
[base] move operationids outside of operations.py
[blockchain] fix class variable
[blockchain] fix get_block_from_time
[blockchain] make mode a variable of the instance
[blockchain] minor tweak
[blockchain] simplify stream and reduce load in RPC for virtual_ops only
[blockchain] stream() now uses two different api calls depending on the set of ops to filter for
[blockchain] updates of blockchain class
[blockchain] use default parameters for blocks()
[blog,post] Properly load Blog posts and fix api terminology
[blog] Blog is now an efficient iterator, implementing steemit like lazy infinite scroll
[blog] cleanup module loading
[blog] list has no item()
[converter] Commenting
[converter] can now compute with Amount objects
[converter] fix sbd_median_price
[converter] fix steem_per_mvests
[converter] move caches to .utils entirely
[depracation warning] Markets and Tickers
[dict] dictification
[docs] update of docs
[docs] update of documentation
[error] exception handling for unhandled but decodeable RPC Errors
[examples] imported examples from steemtools
[examples] updated examples
[exceptions] add Duplicate tx failed exception
[exceptions] added missing file
[exceptions] do not use BroadCastError anymore, instead reraise RPCError
[exceptions] initial work on nicer exception handling
[exceptions] setup more exceptions
[execptions] improve regular expression for error handling
[keystorage] only ask for new wallet when using keystorage
[lazyness] allow to enable lazy loading, no lazy by default
[markets]  avg_witness_price now includes quote price in its calculation
[markets] implemented weighted average function, removed dependence on numpy
[operations] comment_options
[post,steem] steem instance on post is now an optional
[post] allow to set comment options from loaded post
[post] cleaned up the Post object and its methods
[post] correction of fa48ffca06, self.refresh() is only required on @property methods
[post] fix #18
[post] fix amounts and parse 'tags'
[post] fixed regressions caused by Post refactoring
[post] imported superset methods from steemtools
[post] improve loading time
[post] legacy api compatibility
[post] make Post a dictionary and use caching
[post] make sure there us a 'tags' even for comments
[post] methods on Post cannot access 'self'' properties without calling self.refresh() first
[post] minor tweak
[post] more parseing and fixed export()
[post] payout amounts are now also parsed as Amount
[post] re-added meta helper
[rename] transaction -> transactionbuilder
[setup.py] added missing python-dateutil
[setup] linting
[steem.post] allow to define comment options
[steem.transactions] minor fixes
[steem] Remove SteemConnector
[steem] Update steem slightly
[steem] added follow api to the defaults
[steem] allow a list of ops to be signed
[steem] comment_options
[steem] fix import cycles for convenience classes such as Blockchain, Account...
[steem] get_post call
[steem] implemented some of steemtools transactions (without tests)
[steem] make use of module instead of calling rpc directly
[steem] make wallet and rpc static variables
[steem] re-add the broadcast call
[steem] reraise broadcast errors not overwrite them
[steem] use Account() frequently
[steemapi] bypass operation type filtering if rpc.stream receives falsy opNames
[steemtools] integrated Account and Converter modules
[steemtools] integrated Markets module
[steemtools] integrated the Blockchain module
[storage] make sure nonexisting keys can be updated
[tests]
[utils] improted utils from steemtools
[utils] improved dictionary filtering utilities
[utils] improved formatting
[utils] improved is_comment documentation
[utils] improved is_comment function
[utils] re-added missing functions
[utils] refactored is_comment
[utils] refactored time handling functions
[utils] remove dependence on dateutil
[utils] time_elapsed can accept strings as well as datetime objects
[wallet] do not require a wallet if not require keys
[wallet] make the keyMap a singleton
[witness] add witness class
Sort:  

This is a pretty significant release, and due to the substantial refactoring and re-design efforts, it is not fully backwards compatible.

If your project depends on the old version of the piston stack, I encourage you to skim trough the documentation and play with some core utilities in REPL to get a feel for underlying changes and a plethora of new features.

it is not fully backwards compatible.

Thanks for the heads-up.

Thanks for posting the extra goodness our way and keep us all up to date on the matters. Great job! All for one and one for all! Namaste :)

This post has been ranked within the top 10 most undervalued posts in the second half of Jan 18. We estimate that this post is undervalued by $27.35 as compared to a scenario in which every voter had an equal say.

See the full rankings and details in The Daily Tribune: Jan 18 - Part II. You can also read about some of our methodology, data analysis and technical details in our initial post.

If you are the author and would prefer not to receive these comments, simply reply "Stop" to this comment.

Always great to see the work you are doing for the platform!

I JUST got a Raspberry Pi 3 Monday, and installed Piston on it. I wrote a few test programs to interact with steem; very cool and fun!

So do I need to do
pip3 install --upgrade steem
or not? I'm not sure! :-)

If all works fine, you don't need to. It's just a bit nicer.
You will also see a new release of piston quite soon.

Once you updated piston, you will probably see a couple warning messages. That is because most of piston's "library"-sh functions have been moved to python-steem. You can upgrade you code afterwards by simply replacing

from piston.XXXXX import YYYYYY

to

from steem.XXXXXX import YYYYY

You guys are really pushing the boat out, I don't see as much help on other blockchains! Thanks for all your efforts.

Thanks for this kind Sir!!

Providing Keys: Here, you can provide the keys for your accounts manually. All you need to do is add the wif keys for the accounts you want to use as a simple array using the keys parameter to Steem().

how do i provide a single key as a simple array ?

i checked steem.py to see "kwargs " and "keys" somewhere ...
I don't understand, how that's supposed to work.

I like the functions that came with steemtools. Good Work.

You can do like this:

steem = Steem(keys=['wif1', 'wif2'])

I tried a list.

It then asks me for a passphrase to my new wallet.
It doesn't use the key/ doesn't take the argument.

Thanks for the bug report. It fixed it here

Thanks !

And so quick :D !

It still doesn't accept the keys.

You need the develop branch from github!

Thanks.

git clone -b develop https://github.com/xeroc/python-steem/

and then

 python3 setup.py install --user

That works until i get this error:

Processing dependencies for steem==0.4.1
error: requests 2.13.0 is installed but requests==2.10.0 is required by {'graphenelib'}

(my requests version is 2.10.0)

Hmm...
I thought I updated the graphenelibs to not require requests-2.10 but allow others aswell.
You can use the graphenelibs from the minimal branch on https://github.com/xeroc/python-graphenelib
That branch will become the new graphenelib once I finished the new python-bitshares library :)

Coin Marketplace

STEEM 0.21
TRX 0.24
JST 0.038
BTC 94514.58
ETH 3259.44
USDT 1.00
SBD 3.16