-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
74 additions
and
33 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
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,2 +1,6 @@ | ||
"All components of the public interface" | ||
|
||
from .control import Control | ||
from .models import Network | ||
|
||
__all__ = ['Control', 'Network'] |
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,35 +1,39 @@ | ||
"Utility functions" | ||
|
||
import os | ||
import tempfile | ||
import stat | ||
|
||
from functools import wraps | ||
from os.path import dirname, join as pathjoin | ||
from os.path import join as pathjoin | ||
|
||
|
||
def safe_decode(b): | ||
def safe_decode(val): | ||
"Try to decode bytes to str" | ||
try: | ||
return b.decode('utf-8') | ||
return val.decode('utf-8') | ||
except AttributeError: | ||
return b | ||
return val | ||
|
||
|
||
def tempnam(dir: str, prefix: str='') -> str: | ||
def tempnam(dir: str, prefix: str='') -> str: # pylint: disable=redefined-builtin | ||
""" | ||
Utility function. | ||
Creates a temporary file, but removes and closes the file. In effect | ||
it creates a temporary path (that does not exist). For use as a socket | ||
address. | ||
""" | ||
fd, path = tempfile.mkstemp(dir=dir, prefix=prefix) | ||
fd, path = tempfile.mkstemp(dir=dir, prefix=prefix) # pylint: disable=invalid-name | ||
os.close(fd) | ||
os.remove(path) | ||
return path | ||
|
||
|
||
def is_sock(path): | ||
"Checks if given path is a socket" | ||
return stat.S_ISSOCK(os.stat(path).st_mode) | ||
|
||
|
||
def find_sockets(dir): | ||
return [path for path in os.listdir(dir) if is_sock(pathjoin(dir, path))] | ||
def find_sockets(path): | ||
"Finds sockets in given directory" | ||
return [n for n in os.listdir(path) if is_sock(pathjoin(path, n))] |
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,2 +1,2 @@ | ||
# Do not edit. See setup.py. | ||
"Do not edit. See setup.py." | ||
__version__ = "0.9.0" |
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