Skip to content
Snippets Groups Projects
Commit 20070c22 authored by roadscape's avatar roadscape
Browse files

lint

parent eeaac798
No related branches found
No related tags found
No related merge requests found
...@@ -52,6 +52,7 @@ def is_permitted(account: str, community: str, action: str) -> bool: ...@@ -52,6 +52,7 @@ def is_permitted(account: str, community: str, action: str) -> bool:
def get_user_role(account: str, community: str) -> str: def get_user_role(account: str, community: str) -> str:
"""Get user role within a specific community."""
if account == community: if account == community:
return 'owner' return 'owner'
...@@ -76,6 +77,7 @@ def get_user_role(account: str, community: str) -> str: ...@@ -76,6 +77,7 @@ def get_user_role(account: str, community: str) -> str:
def get_community_privacy(community: str) -> str: def get_community_privacy(community: str) -> str:
"""Load community privacy level"""
type_id = query_one('SELECT type_id from hive_communities WHERE name = "%s"' % community) type_id = query_one('SELECT type_id from hive_communities WHERE name = "%s"' % community)
return PRIVACY_MAP.get(type_id) return PRIVACY_MAP.get(type_id)
......
...@@ -5,6 +5,8 @@ import re ...@@ -5,6 +5,8 @@ import re
import atexit import atexit
from hive.utils.system import colorize, peak_usage_mb from hive.utils.system import colorize, peak_usage_mb
# pylint: disable=missing-docstring
class QueryStats: class QueryStats:
SLOW_QUERY_MS = 250 SLOW_QUERY_MS = 250
......
...@@ -11,6 +11,7 @@ FOLLOWERS = 'followers' ...@@ -11,6 +11,7 @@ FOLLOWERS = 'followers'
FOLLOWING = 'following' FOLLOWING = 'following'
class Follow: class Follow:
"""Handles processing of incoming follow ups and flushing to db."""
@classmethod @classmethod
def follow_op(cls, account, op_json, date): def follow_op(cls, account, op_json, date):
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
import atexit import atexit
from hive.utils.system import colorize, peak_usage_mb from hive.utils.system import colorize, peak_usage_mb
# pylint: disable=missing-docstring
class ClientStats: class ClientStats:
"""Collects steemd API timing data.""" """Collects steemd API timing data."""
......
...@@ -109,7 +109,6 @@ class HttpClient(object): ...@@ -109,7 +109,6 @@ class HttpClient(object):
get_order_book='condenser_api', get_order_book='condenser_api',
get_feed_history='condenser_api', get_feed_history='condenser_api',
get_dynamic_global_properties='database_api', get_dynamic_global_properties='database_api',
broadcast_transaction_synchronous='network_broadcast_api', # temporary; for testing condenser_api
) )
def __init__(self, nodes, **kwargs): def __init__(self, nodes, **kwargs):
......
...@@ -15,6 +15,7 @@ class SteemClient: ...@@ -15,6 +15,7 @@ class SteemClient:
@classmethod @classmethod
def instance(cls): def instance(cls):
"""Get a singleton, lazily initialized"""
if not cls._instance: if not cls._instance:
cls._instance = SteemClient( cls._instance = SteemClient(
url=Conf.get('steemd_url'), url=Conf.get('steemd_url'),
...@@ -35,13 +36,16 @@ class SteemClient: ...@@ -35,13 +36,16 @@ class SteemClient:
% (url, max_batch, max_workers)) % (url, max_batch, max_workers))
def get_accounts(self, accounts): def get_accounts(self, accounts):
"""Fetch multiple accounts by name."""
assert accounts, "no accounts passed to get_accounts" assert accounts, "no accounts passed to get_accounts"
assert len(accounts) <= 1000, "max 1000 accounts"
ret = self.__exec('get_accounts', [accounts]) ret = self.__exec('get_accounts', [accounts])
assert len(accounts) == len(ret), ("requested %d accounts got %d" assert len(accounts) == len(ret), ("requested %d accounts got %d"
% (len(accounts), len(ret))) % (len(accounts), len(ret)))
return ret return ret
def get_content_batch(self, tuples): def get_content_batch(self, tuples):
"""Fetch multiple comment objects."""
posts = self.__exec_batch('get_content', tuples) posts = self.__exec_batch('get_content', tuples)
# TODO: how are we ensuring sequential results? need to set and sort id. # TODO: how are we ensuring sequential results? need to set and sort id.
for post in posts: # sanity-checking jussi responses for post in posts: # sanity-checking jussi responses
...@@ -141,12 +145,15 @@ class SteemClient: ...@@ -141,12 +145,15 @@ class SteemClient:
return ret return ret
def head_time(self): def head_time(self):
"""Get timestamp of head block"""
return self._gdgp()['time'] return self._gdgp()['time']
def head_block(self): def head_block(self):
"""Get head block number"""
return self._gdgp()['head_block_number'] return self._gdgp()['head_block_number']
def last_irreversible(self): def last_irreversible(self):
"""Get last irreversible block"""
return self._gdgp()['last_irreversible_block_num'] return self._gdgp()['last_irreversible_block_num']
def gdgp_extended(self): def gdgp_extended(self):
......
...@@ -6,11 +6,13 @@ import resource ...@@ -6,11 +6,13 @@ import resource
USE_COLOR = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty() USE_COLOR = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
def colorize(string, color='93'): def colorize(string, color='93'):
"""Colorizes a string for stdout, if attached to terminal"""
if not USE_COLOR: if not USE_COLOR:
return string return string
return "\033[%sm%s\033[0m" % (color, string) return "\033[%sm%s\033[0m" % (color, string)
def peak_usage_mb(): def peak_usage_mb():
"""Get peak memory usage of hive process."""
mem_denom = (1024 * 1024) if sys.platform == 'darwin' else 1024 mem_denom = (1024 * 1024) if sys.platform == 'darwin' else 1024
max_mem = int(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss) max_mem = int(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss)
return max_mem / mem_denom return max_mem / mem_denom
...@@ -260,7 +260,7 @@ single-line-if-stmt=no ...@@ -260,7 +260,7 @@ single-line-if-stmt=no
no-space-check=trailing-comma,dict-separator no-space-check=trailing-comma,dict-separator
# Maximum number of lines in a module # Maximum number of lines in a module
max-module-lines=1000 max-module-lines=250
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
# tab). # tab).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment