From 5f9c0f7b1bdabba487d9d25e3f96189757aec87e Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Thu, 8 Dec 2016 16:46:07 +0100 Subject: [PATCH] Fix docstring rst errors in the backend modules --- bigchaindb/backend/connection.py | 4 ++-- bigchaindb/backend/query.py | 8 ++++---- bigchaindb/backend/rethinkdb/connection.py | 13 +++++++------ bigchaindb/backend/schema.py | 20 ++++++++++---------- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/bigchaindb/backend/connection.py b/bigchaindb/backend/connection.py index 01a51e28..0f0b9243 100644 --- a/bigchaindb/backend/connection.py +++ b/bigchaindb/backend/connection.py @@ -9,7 +9,7 @@ BACKENDS = { def connect(backend=None, host=None, port=None, name=None): - '''Create a connection to a database. + """Create a connection to the database backend. Args: backend (str): the name of the backend to use. @@ -19,7 +19,7 @@ def connect(backend=None, host=None, port=None, name=None): Returns: An instance of :class:`~bigchaindb.backend.connection.Connection`. - ''' + """ backend = backend or bigchaindb.config['database']['backend'] host = host or bigchaindb.config['database']['host'] diff --git a/bigchaindb/backend/query.py b/bigchaindb/backend/query.py index a3fe29ef..e9fe0b46 100644 --- a/bigchaindb/backend/query.py +++ b/bigchaindb/backend/query.py @@ -94,7 +94,7 @@ def get_transaction_from_backlog(connection, transaction_id): @singledispatch def get_blocks_status_from_transaction(connection, transaction_id): - """Retrieve block election information given a secondary index and value + """Retrieve block election information given a secondary index and value. Args: value: a value to search (e.g. transaction id string, payload hash string) @@ -120,7 +120,7 @@ def get_txids_by_asset_id(connection, asset_id): Returns: A list of transactions ids related to the asset. If no transaction - exists for that asset it returns an empty list `[]` + exists for that asset it returns an empty list ``[]`` """ raise NotImplementedError @@ -218,7 +218,7 @@ def write_block(connection, block): @singledispatch def get_block(connection, block_id): - """Get a block from the bigchain table + """Get a block from the bigchain table. Args: block_id (str): block id of the block to get @@ -282,7 +282,7 @@ def write_vote(connection, vote): @singledispatch def get_genesis_block(connection): - """Get the genesis block + """Get the genesis block. Returns: The genesis block diff --git a/bigchaindb/backend/rethinkdb/connection.py b/bigchaindb/backend/rethinkdb/connection.py index 9fb7a5d2..03c2508c 100644 --- a/bigchaindb/backend/rethinkdb/connection.py +++ b/bigchaindb/backend/rethinkdb/connection.py @@ -9,11 +9,12 @@ logger = logging.getLogger(__name__) class RethinkDBConnection(Connection): - """This class is a proxy to run queries against the database, - it is: - - lazy, since it creates a connection only when needed - - resilient, because before raising exceptions it tries - more times to run the query or open a connection. + """ + This class is a proxy to run queries against the database, it is: + + - lazy, since it creates a connection only when needed + - resilient, because before raising exceptions it tries + more times to run the query or open a connection. """ def __init__(self, host, port, dbname, max_tries=3): @@ -34,7 +35,7 @@ class RethinkDBConnection(Connection): self.conn = None def run(self, query): - """Run a query. + """Run a RethinkDB query. Args: query: the RethinkDB query. diff --git a/bigchaindb/backend/schema.py b/bigchaindb/backend/schema.py index 6c5b0720..b3ae8fab 100644 --- a/bigchaindb/backend/schema.py +++ b/bigchaindb/backend/schema.py @@ -8,14 +8,14 @@ from bigchaindb.backend.connection import connect @singledispatch def create_database(connection, dbname): - """Create database to be used by BigchainDB + """Create database to be used by BigchainDB. Args: dbname (str): the name of the database to create. Raises: - :exc:`~bigchaindb.common.exceptions.DatabaseAlreadyExists`: If the - given :attr:`dbname` already exists as a database. + :exc:`~DatabaseAlreadyExists`: If the given :attr:`dbname` already + exists as a database. """ raise NotImplementedError @@ -23,7 +23,7 @@ def create_database(connection, dbname): @singledispatch def create_tables(connection, dbname): - """Create the tables to be used by BigchainDB + """Create the tables to be used by BigchainDB. Args: dbname (str): the name of the database to create tables for. @@ -34,7 +34,7 @@ def create_tables(connection, dbname): @singledispatch def create_indexes(connection, dbname): - """Create the indexes to be used by BigchainDB + """Create the indexes to be used by BigchainDB. Args: dbname (str): the name of the database to create indexes for. @@ -45,14 +45,14 @@ def create_indexes(connection, dbname): @singledispatch def drop_database(connection, dbname): - """Drop the database used by BigchainDB + """Drop the database used by BigchainDB. Args: dbname (str): the name of the database to drop. Raises: - :exc:`~bigchaindb.common.exceptions.DatabaseDoesNotExist`: If the - given :attr:`dbname` does not exist as a database. + :exc:`~DatabaseDoesNotExist`: If the given :attr:`dbname` does not + exist as a database. """ raise NotImplementedError @@ -73,8 +73,8 @@ def init_database(connection=None, dbname=None): configuration. Raises: - :exc:`~bigchaindb.common.exceptions.DatabaseAlreadyExists`: If the - given :attr:`dbname` already exists as a database. + :exc:`~DatabaseAlreadyExists`: If the given :attr:`dbname` already + exists as a database. """ connection = connection or connect()