-
Notifications
You must be signed in to change notification settings - Fork 247
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 #200 from rossant/pyks2
Experimental Python port of Kilosort 2
- Loading branch information
Showing
28 changed files
with
6,751 additions
and
0 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,40 @@ | ||
import logging | ||
import os.path as op | ||
|
||
from .utils import Bunch, memmap_binary_file, read_data, load_probe # noqa | ||
from .main import run # noqa | ||
|
||
|
||
__version__ = '2.0.0a0' | ||
|
||
|
||
# Set a null handler on the root logger | ||
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.DEBUG) | ||
|
||
|
||
_logger_fmt = '%(asctime)s.%(msecs)03d [%(levelname)s] %(caller)s %(message)s' | ||
_logger_date_fmt = '%H:%M:%S' | ||
|
||
|
||
class _Formatter(logging.Formatter): | ||
def format(self, record): | ||
# Only keep the first character in the level name. | ||
record.levelname = record.levelname[0] | ||
filename = op.splitext(op.basename(record.pathname))[0] | ||
record.caller = '{:s}:{:d}'.format(filename, record.lineno).ljust(20) | ||
message = super(_Formatter, self).format(record) | ||
color_code = {'D': '90', 'I': '0', 'W': '33', 'E': '31'}.get(record.levelname, '7') | ||
message = '\33[%sm%s\33[0m' % (color_code, message) | ||
return message | ||
|
||
|
||
def add_default_handler(level='INFO', logger=logger, filename=None): | ||
if filename is None: | ||
handler = logging.StreamHandler() | ||
else: | ||
handler = logging.FileHandler(filename) | ||
handler.setLevel(level) | ||
formatter = _Formatter(fmt=_logger_fmt, datefmt=_logger_date_fmt) | ||
handler.setFormatter(formatter) | ||
logger.addHandler(handler) |
Oops, something went wrong.