-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from ZigmundVonZaun/fady
Fady: Documentation and minor linting.
- Loading branch information
Showing
10 changed files
with
180 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
K_BUCKET_SIZE = 20 | ||
ID_BITS = 128 | ||
ITERATION_SLEEP = 1 | ||
ALPHA = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,8 @@ venv/ | |
|
||
# IntelliJ | ||
|
||
.idea/ | ||
.idea/ | ||
|
||
# Environmental Variables | ||
|
||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,46 @@ | ||
import shelve | ||
|
||
|
||
def test(): | ||
pass | ||
|
||
|
||
class Shelve: | ||
""" | ||
It works like Python 2s pickle | ||
""" | ||
def __init__(self, f): | ||
""" | ||
Initialises a shelf for object persistence against instances | ||
:param f: file path pointing to external file shelf should use | ||
""" | ||
self.shelve = shelve.open(f) | ||
|
||
def dump(self): | ||
""" | ||
Shows all saved keys within the file | ||
:return: stdout output of all keys in the shelf | ||
""" | ||
for x in self.shelve: | ||
print('key:', x, '\t\tvalue:', self.shelve[x]) | ||
|
||
def __getitem__(self, key): | ||
""" | ||
Gets a key within the shelf | ||
:param key: Specifies the key of the object within the shelf | ||
:return: Returns a value from the shelf | ||
""" | ||
return self.shelve[str(key)] | ||
|
||
def __setitem__(self, key, value): | ||
""" | ||
Sets a key and its respective value into the shelf. | ||
:param key: Key for later reindexing | ||
:param value: Value to save | ||
:return: None | ||
""" | ||
self.shelve[str(key)] = value | ||
|
||
def __contains__(self, key): | ||
""" | ||
Checks whether a key exists in the shelf. | ||
:param key: Specifies the key to check | ||
:return: Key if it exists | ||
""" | ||
return str(key) in self.shelve |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
matplotlib | ||
networkx | ||
logbook | ||
logbook | ||
python-dotenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import unittest | ||
from pathlib import Path | ||
|
||
from dht.peer import Peer | ||
|
||
|
||
class PeerTest(unittest.TestCase): | ||
def setUp(self): | ||
pass | ||
|
||
def test_peer(self): | ||
peer = Peer("localhost", 9789, "foo", "bar") | ||
self.assertEqual(str(peer), "localhost:9789") |