Added docstrings in manager
This commit is contained in:
parent
f3ddf868a7
commit
64d73998c2
|
@ -62,6 +62,7 @@ class Manager(threading.Thread):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def clean_objects():
|
def clean_objects():
|
||||||
|
"""Remove expired objects"""
|
||||||
for vector in set(shared.objects):
|
for vector in set(shared.objects):
|
||||||
# FIXME: no need to check is_valid() here
|
# FIXME: no need to check is_valid() here
|
||||||
if shared.objects[vector].is_expired():
|
if shared.objects[vector].is_expired():
|
||||||
|
@ -176,7 +177,7 @@ class Manager(threading.Thread):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load_data():
|
def load_data():
|
||||||
"""Loads initial nodes and data, stored in files between sessions"""
|
"""Load initial nodes and data, stored in files between sessions"""
|
||||||
try:
|
try:
|
||||||
with open(
|
with open(
|
||||||
os.path.join(shared.data_directory, 'objects.pickle'), 'br'
|
os.path.join(shared.data_directory, 'objects.pickle'), 'br'
|
||||||
|
@ -229,6 +230,7 @@ class Manager(threading.Thread):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def pickle_objects():
|
def pickle_objects():
|
||||||
|
"""Save objects into a file objects.pickle in the data directory"""
|
||||||
try:
|
try:
|
||||||
with open(
|
with open(
|
||||||
os.path.join(shared.data_directory, 'objects.pickle'), 'bw'
|
os.path.join(shared.data_directory, 'objects.pickle'), 'bw'
|
||||||
|
@ -241,6 +243,7 @@ class Manager(threading.Thread):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def pickle_nodes():
|
def pickle_nodes():
|
||||||
|
"""Save nodes into files in the data directory"""
|
||||||
if len(shared.node_pool) > 10000:
|
if len(shared.node_pool) > 10000:
|
||||||
shared.node_pool = set(random.sample(
|
shared.node_pool = set(random.sample(
|
||||||
tuple(shared.node_pool), 10000))
|
tuple(shared.node_pool), 10000))
|
||||||
|
@ -270,6 +273,7 @@ class Manager(threading.Thread):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def publish_i2p_destination():
|
def publish_i2p_destination():
|
||||||
|
"""Make and publish a special object, containing the I2P destination"""
|
||||||
if shared.i2p_session_nick and not shared.i2p_transient:
|
if shared.i2p_session_nick and not shared.i2p_transient:
|
||||||
logging.info('Publishing our I2P destination')
|
logging.info('Publishing our I2P destination')
|
||||||
dest_pub_raw = base64.b64decode(
|
dest_pub_raw = base64.b64decode(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user