Skip to content

Commit

Permalink
Improved formating
Browse files Browse the repository at this point in the history
  • Loading branch information
holgern committed Oct 24, 2020
1 parent f1529e7 commit 4beb960
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 35 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ Changelog
* Add option add_tor to config storage, which allows it to use beempy in tails
* Switch from pyyaml to ruamel.yaml
* Remove Events requirements, beem.notify and beemapi.websocket, as it is not well tested and there are no websocket api nodes available on hive
* Remove unnecessary requirements (pylibscrypt and future
* Remove unnecessary requirements (pylibscrypt and future)
* add new node (fin.hive.3speak.co) and change change rpc.esteem.app to rpc.ecency.com
* Replace diff_match_patch by difflib and add unit tests
* Increase timeout and retry cound in beempy
* Increase timeout and retry count in beempy
* Remove obsolete replace_hive_by_steem parameter
* skip_account_check added to account.transfer and account.transfer_to_vesting

0.24.13
-------
Expand Down
2 changes: 1 addition & 1 deletion beem/blockchaininstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from datetime import datetime, timedelta, date
from beemapi.noderpc import NodeRPC
from beemgraphenebase.account import PrivateKey, PublicKey
from beembase import transactions, operations
from beembase import operations
from beemgraphenebase.chains import known_chains
from .storage import get_default_config_store
from .account import Account
Expand Down
61 changes: 29 additions & 32 deletions beemstorage/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def sql_execute(self, query, lastid=False):
cursor = connection.cursor()
cursor.execute(*query)
connection.commit()
except:
except Exception:
connection.close()
raise
ret = None
Expand Down Expand Up @@ -207,10 +207,10 @@ def _haveKey(self, key):
"""
query = (
"SELECT {} FROM {} WHERE {}=?".format(
self.__value__,
self.__tablename__,
self.__key__
), (key,))
self.__value__, self.__tablename__, self.__key__
),
(key,),
)
return True if self.sql_fetchone(query) else False

def __setitem__(self, key, value):
Expand Down Expand Up @@ -242,10 +242,10 @@ def __getitem__(self, key):
"""
query = (
"SELECT {} FROM {} WHERE {}=?".format(
self.__value__,
self.__tablename__,
self.__key__
), (key,))
self.__value__, self.__tablename__, self.__key__
),
(key,),
)
result = self.sql_fetchone(query)
if result:
return result[0]
Expand All @@ -261,15 +261,13 @@ def __iter__(self):
return iter(self.keys())

def keys(self):
query = ("SELECT {} from {}".format(
self.__key__,
self.__tablename__), )
query = ("SELECT {} from {}".format(self.__key__, self.__tablename__),)
return [x[0] for x in self.sql_fetchall(query)]

def __len__(self):
""" return lenght of store
"""
query = ("SELECT id from {}".format(self.__tablename__), )
query = ("SELECT id from {}".format(self.__tablename__),)
return len(self.sql_fetchall(query))

def __contains__(self, key):
Expand All @@ -287,10 +285,11 @@ def __contains__(self, key):
def items(self):
""" returns all items off the store as tuples
"""
query = ("SELECT {}, {} from {}".format(
self.__key__,
self.__value__,
self.__tablename__), )
query = (
"SELECT {}, {} from {}".format(
self.__key__, self.__value__, self.__tablename__
),
)
r = []
for key, value in self.sql_fetchall(query):
r.append((key, value))
Expand All @@ -314,39 +313,37 @@ def delete(self, key):
:param str value: Value
"""
query = (
"DELETE FROM {} WHERE {}=?".format(
self.__tablename__,
self.__key__
), (key,))
"DELETE FROM {} WHERE {}=?".format(self.__tablename__, self.__key__),
(key,),
)
self.sql_execute(query)

def wipe(self):
""" Wipe the store
"""
query = ("DELETE FROM {}".format(self.__tablename__), )
query = ("DELETE FROM {}".format(self.__tablename__),)
self.sql_execute(query)

def exists(self):
""" Check if the database table exists
"""
query = ("SELECT name FROM sqlite_master " +
"WHERE type='table' AND name=?",
(self.__tablename__, ))
query = (
"SELECT name FROM sqlite_master " + "WHERE type='table' AND name=?",
(self.__tablename__,),
)
return True if self.sql_fetchone(query) else False

def create(self): # pragma: no cover
""" Create the new table in the SQLite database
"""
query = ((
"""
query = (
(
"""
CREATE TABLE {} (
id INTEGER PRIMARY KEY AUTOINCREMENT,
{} STRING(256),
{} STRING(256)
)"""
).format(
self.__tablename__,
self.__key__,
self.__value__
), )
).format(self.__tablename__, self.__key__, self.__value__),
)
self.sql_execute(query)

0 comments on commit 4beb960

Please sign in to comment.