diff --git a/beem/account.py b/beem/account.py index 7411ca3df56a1c641434668ca46ab949fc4f2dc8..817dd803ce40230e11900189e69755eb5de21ac9 100644 --- a/beem/account.py +++ b/beem/account.py @@ -184,8 +184,8 @@ class Account(BlockchainObject): >>> from beem.account import Account >>> account = Account("test") - >>> print(account.get_similar_account_names(limit=5)) - ['test', 'test-1', 'test-2', 'test-ico', 'test-ilionx-123'] + >>> len(account.get_similar_account_names(limit=5)) + 5 """ if self.steem.rpc.get_use_appbase(): diff --git a/beem/asciichart.py b/beem/asciichart.py index b06b7f9008b3da90cf5664fa7debdb7f03f71e05..b88223449cc43216094df88c7d6ecbf63c5eb961 100644 --- a/beem/asciichart.py +++ b/beem/asciichart.py @@ -87,7 +87,7 @@ class AsciiChart(object): chart.new_chart() chart.add_axis() chart.add_curve(series) - print(str(chart)) # doctest: +SKIP + print(str(chart)) """ self.minimum = min(series) @@ -134,7 +134,7 @@ class AsciiChart(object): from beem.asciichart import AsciiChart chart = AsciiChart() series = [1, 2, 3, 7, 2, -4, -2] - chart.plot(series) # doctest: +SKIP + chart.plot(series) """ self.clear_data() self.adapt_on_series(series) @@ -158,7 +158,7 @@ class AsciiChart(object): chart.new_chart() chart.add_axis() chart.add_curve(series) - print(str(chart)) # doctest: +SKIP + print(str(chart)) """ if minimum is not None: @@ -182,7 +182,7 @@ class AsciiChart(object): chart.new_chart() chart.add_axis() chart.add_curve(series) - print(str(chart)) # doctest: +SKIP + print(str(chart)) """ # axis and labels @@ -220,7 +220,7 @@ class AsciiChart(object): chart.new_chart() chart.add_axis() chart.add_curve(series) - print(str(chart)) # doctest: +SKIP + print(str(chart)) """ if self.n is None: diff --git a/beem/instance.py b/beem/instance.py index 2efe17fe1546da98cb7dc5bc3850f42ce82ceef2..ec89ca247532e3f5db3d095cac7b371c943b81d1 100644 --- a/beem/instance.py +++ b/beem/instance.py @@ -38,7 +38,7 @@ def set_shared_steem_instance(steem_instance): """ This method allows us to override default steem instance for all users of ``SharedInstance.instance``. - :param steem.steem.Steem steem_instance: Steem instance + :param beem.steem.Steem steem_instance: Steem instance """ clear_cache() SharedInstance.instance = steem_instance diff --git a/beem/profile.py b/beem/profile.py index c44397ecf3d21b5b62bb42a7160358978e9cc1eb..10896572ad65d007600d056bcafee60155c8c7e8 100644 --- a/beem/profile.py +++ b/beem/profile.py @@ -16,8 +16,9 @@ class DotDict(dict): >>> from beem.profile import Profile >>> keys = ['profile.url', 'profile.img'] >>> values = ["http:", "foobar"] - >>> print(Profile(keys, values)) - {"profile": {"url": "http:", "img": "foobar"}} + >>> p = Profile(keys, values) + >>> print(p["profile"]["url"]) + http: """ if len(args) == 2: diff --git a/docs/cli.rst b/docs/cli.rst index 9ddd26a56296f04278e0c62020b268606fcfc3e6..09f1f86183af25afe14fbacb39498b4c1e64812b 100644 --- a/docs/cli.rst +++ b/docs/cli.rst @@ -90,9 +90,15 @@ If you've set up your `default_account`, you can now send funds by omitting this beempy transfer <recipient_name> 100 STEEM memo +Commands +-------- -Help ----- +.. click:: beem.cli:cli + :prog: beempy + :show-nested: + +beempy --help +------------- You can see all available commands with ``beempy --help`` :: diff --git a/docs/conf.py b/docs/conf.py index df582ea79455dc0ac173194ce448ccc7717d2330..a636deddc3d9e013eb0d5975f7bf63ec85017bd7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -31,7 +31,7 @@ sys.path.insert(0, os.path.abspath('../scripts/')) # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ["sphinx.ext.autodoc", "sphinx.ext.doctest"] +extensions = ["sphinx.ext.autodoc", "sphinx.ext.doctest", "sphinx_click.ext"] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/docs/configuration.rst b/docs/configuration.rst index b69c73a95d57492be6d74084d7051789982eec5c..278165a5ef8b37a8ac1c63a71f4fd2fbd31baf1e 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -5,9 +5,11 @@ Configuration The pysteem library comes with its own local configuration database that stores information like -* API node URL +* API node URLs * default account name * the encrypted master password +* the default voting weight +* if keyring should be used for unlocking the wallet and potentially more. @@ -21,10 +23,127 @@ You can access those variables like a regular dictionary by using Keys can be added and changed like they are for regular dictionaries. -If you don't want to load the :class:`steem.Steem` class, you +If you don't want to load the :class:`beem.Steem` class, you can load the configuration directly by using: .. code-block:: python from beem.storage import configStorage as config +It is also possible to access the configuration with the commandline tool `beempy`: + +.. code-block:: bash + + beempy config + +API node URLs +------------- + +The default node URLs which will be used when `node` is `None` in :class:`beem.Steem` class +is stored in `config["nodes"]` as string. The list can be get and set by: + +.. code-block:: python + + from beem import Steem + steem = Steem() + node_list = steem.get_default_nodes() + node_list = node_list[1:] + [node_list[0]] + steem.set_default_nodes(node_list) + +beempy can also be used to set nodes: + +.. code-block:: bash + + beempy set nodes wss://steemd.privex.io + beempy set nodes "['wss://steemd.privex.io', 'wss://gtg.steem.house:8090']" + +The default nodes can be resetted to the default value. When the first node does not +answer, steem should be set to the offline mode. This can be done by: + +.. code-block:: bash + + beempy -o set nodes "" + +or + +.. code-block:: python + + from beem import Steem + steem = Steem(offline=True) + steem.set_default_nodes("") + +Default account +--------------- + +The default account name is used in some functions, when no account name is given. +It is also used in `beempy` for all account related functions. + +.. code-block:: python + + from beem import Steem + steem = Steem() + steem.set_default_account("test") + steem.config["default_account"] = "test" + +or by beempy with + +.. code-block:: bash + + beempy set default_account test + +Default voting weight +--------------------- + +The default vote weight is used for voting, when no vote weight is given. + +.. code-block:: python + + from beem import Steem + steem = Steem() + steem.config["default_vote_weight"] = 100 + +or by beempy with + +.. code-block:: bash + + beempy set default_vote_weight 100 + + +Setting password_storage +------------------------ + +The password_storage can be set to: + +* environment, this is the default setting. The master password for the wallet can be provided in the environment variable `UNLOCK`. +* keyring + +.. code-block:: python + + from beem import Steem + steem = Steem() + steem.config["password_storage"] = "environment" + steem.config["password_storage"] = "keyring" + +or by beempy with + +.. code-block:: bash + + beempy set password_storage environment + beempy set password_storage keyring + +Testing if the master password is correctly provided by keyring or the `UNLOCK` variable: + +.. code-block:: python + + from beem import Steem + steem = Steem() + print(steem.wallet.locked()) + +When the output is False, automatic unlocking with keyring or the `UNLOCK` variable works. +It can also tested by beempy with + +.. code-block:: bash + + beempy walletinfo --test-unlock + +When no password prompt is shown, unlocking with keyring or the `UNLOCK` variable works. diff --git a/docs/requirements.txt b/docs/requirements.txt index d392dadce1ec3abd93613383d7e5d115b7da9feb..fed1bfabd7a25239c55b625a16c81a2d67726e2c 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -16,3 +16,4 @@ appdirs Click prettytable sphinx_rtd_theme +sphinx-click diff --git a/tox.ini b/tox.ini index bb4551adb38c0b8a706bb0055d12fd6ea70427a4..4c87d14922b6ee3844bfbac78ecc6fa5c655f41f 100644 --- a/tox.ini +++ b/tox.ini @@ -128,6 +128,7 @@ changedir= docs deps=-rdocs/requirements.txt sphinx + sphinx-click commands= sphinx-build -b html ./ ./html