Skip to content

Commit

Permalink
Merge pull request #8 from dandi/enh-ls
Browse files Browse the repository at this point in the history
ENH: rudimentary ls and validate commands
  • Loading branch information
yarikoptic committed Oct 7, 2019
2 parents 049d366 + 39cd875 commit cf22b03
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.eggs
.idea
.*.swp
*.egg-info/
dist/
pip-wheel-metadata/
sandbox/
venvs/

22 changes: 22 additions & 0 deletions dandi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
import logging

from . import _version

__version__ = _version.get_versions()['version']


#
# Basic logger configuration
#


def get_logger(name=None):
"""Return a logger to use
"""
return logging.getLogger('dandi' + ('.%s' % name if name else ''))


_DEFAULT_LOG_FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'

lgr = get_logger()
# Basic settings for output, for now just basic
lgr.setLevel(logging.INFO)
FORMAT = '%(asctime)-15s [%(levelname)8s] %(message)s'
logging.basicConfig(format=FORMAT)
37 changes: 37 additions & 0 deletions dandi/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import sys

#
# Additional handlers
#
_sys_excepthook = sys.excepthook # Just in case we ever need original one


def is_interactive():
"""Return True if all in/outs are tty"""
# TODO: check on windows if hasattr check would work correctly and add value:
#
return sys.stdin.isatty() and sys.stdout.isatty() and sys.stderr.isatty()


def setup_exceptionhook(ipython=False):
"""Overloads default sys.excepthook with our exceptionhook handler.
If interactive, our exceptionhook handler will invoke
pdb.post_mortem; if not interactive, then invokes default handler.
"""

def _pdb_excepthook(type, value, tb):
import traceback
traceback.print_exception(type, value, tb)
print()
if is_interactive():
import pdb
pdb.post_mortem(tb)

if ipython:
from IPython.core import ultratb
sys.excepthook = ultratb.FormattedTB(mode='Verbose',
# color_scheme='Linux',
call_pdb=is_interactive())
else:
sys.excepthook = _pdb_excepthook
7 changes: 5 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ install_requires =
girder-client
pynwb >= 1.0.3,!=1.1.0
hdmf != 1.1.2
click
click-didyoumean
pyout
humanize
tests_require =
pytest
# TODO: figure out. For now alias test
Expand Down Expand Up @@ -60,11 +64,10 @@ all =

[options.entry_points]
console_scripts =
dandi=dandi.cmdline:main
dandi=dandi.cli.command:main

[options.package_data]
dandi =
tests/data/*
*/tests/data/*

[flake8]
Expand Down

0 comments on commit cf22b03

Please sign in to comment.