Skip to content

Commit

Permalink
small fixes in README and sth else
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCqk committed Mar 10, 2018
1 parent 7ca899d commit 3fbdbcc
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ db = cannondb.connect(log='local')

# use tcp/udp mode
# host and port must be specified.
db = cannondb.connect(log='tcp', host=127.0.0.1, port=2048)
db = cannondb.connect(log='tcp', host='127.0.0.1', port=2048)
```

###### Do not forget to close db when exit.
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ logging
# use tcp/udp mode
# host and port must be specified.
db = cannondb.connect(log='tcp', host=127.0.0.1, port=2048)
db = cannondb.connect(log='tcp', host='127.0.0.1', port=2048)
Do not forget to close db when exit.

Expand Down
2 changes: 1 addition & 1 deletion cannondb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from cannondb.storages import FileStorage, MemoryStorage
from cannondb.wrapper import log_wrapper

__version__ = '1.1.0'
__version__ = '1.1.1'

__all__ = ('CannonDB', 'FileStorage', 'MemoryStorage')

Expand Down
8 changes: 3 additions & 5 deletions cannondb/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@ def deserialize(data: bytes) -> dict:
0: int,
1: float,
2: str,
3: dict,
int: 0,
float: 1,
str: 2,
dict: 3
3: dict
}

type_num_map.update(dict(zip(type_num_map.values(), type_num_map.keys())))


def serializer_switcher(t: Type[Union[int, float, str, dict]]) -> Serializer:
"""return corresponding serializer to arg type"""
Expand Down
5 changes: 3 additions & 2 deletions cannondb/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@ def log_wrapper(cls, methods_to_log: tuple, log_mode='local', host=None, port=No
orig_cls = cls.__class__
logger = logging.getLogger(orig_cls.__name__)
if log_mode == 'tcp' or log_mode == 'udp':
handler = log_handlers.SocketHandler(host=host, port=port) if log_mode == 'tcp' else log_handlers.DatagramHandler(
handler = log_handlers.SocketHandler(host=host,
port=port) if log_mode == 'tcp' else log_handlers.DatagramHandler(
host=host, port=port)
else:
if not os.path.exists(_log_file_name):
os.open(_log_file_name, os.O_RDWR | os.O_CREAT)
open(_log_file_name, 'a').close()
handler = logging.FileHandler(_log_file_name, mode='r+')
logger.addHandler(handler)

Expand Down

0 comments on commit 3fbdbcc

Please sign in to comment.