Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ronny Eichler
dataman
Commits
e3361618
Commit
e3361618
authored
Mar 04, 2017
by
Ronny Eichler
Browse files
Move DataMan class to single main file
parent
8308bfa4
Changes
2
Hide whitespace changes
Inline
Side-by-side
dataman/dataman.py
View file @
e3361618
...
...
@@ -6,14 +6,62 @@ import sys
import
cmd
import
logging
from
dataman.lib.constants
import
LOG_LEVEL_VERBOSE
from
dataman.dataman_cli
import
DataMan
from
.lib.constants
import
LOG_LEVEL_VERBOSE
__version__
=
0.01
NO_EXIT_CONFIRMATION
=
True
LOG_LEVEL
=
logging
.
INFO
class
DataMan
(
cmd
.
Cmd
):
"""Command line tool for quick data documentation."""
prompt
=
"dm> "
intro
=
"Data Manager
\n
"
def
preloop
(
self
):
self
.
log
=
logging
.
getLogger
(
__name__
)
self
.
log
.
debug
(
"starting DataMan CLI"
)
# process command line arguments etc.
def
do_greet
(
self
,
user
):
"""greet [user name]
Simple user greeting. When used in combination with a parameter, will
respond with personalized greeting. Yay."""
if
user
:
print
(
"hello "
,
user
)
else
:
print
(
"hi there!"
)
def
do_ls
(
self
,
path
):
if
not
len
(
path
):
path
=
'.'
import
dataman.lib.dirstats
as
ds
ds
.
print_table
(
ds
.
gather
(
path
))
def
do_stats
(
self
,
path
):
if
not
len
(
path
):
path
=
'.'
import
dataman.lib.dirstats
as
ds
ds
.
print_table
(
ds
.
gather
(
path
))
def
do_vis
(
self
,
path
):
from
dataman.vis
import
vis
vis
.
run
(
target
=
path
)
def
do_exit
(
self
,
line
):
"Exit"
return
True
def
do_EOF
(
self
,
line
):
"Exit"
return
True
def
postloop
(
self
):
print
(
"Done."
)
def
main
():
# Command line parsing
import
argparse
...
...
@@ -29,12 +77,12 @@ def main():
parser_cli
=
subparsers
.
add_parser
(
'cli'
,
help
=
'Interactive CLI session'
)
# STATS
parser_stats
=
subparsers
.
add_parser
(
'stats'
,
help
=
'Dataset stat
istics
.'
)
parser_stats
=
subparsers
.
add_parser
(
'stats'
,
help
=
'Dataset stat
s (number channels, duration, sampling rate..
.'
)
parser_stats
.
add_argument
(
'path'
,
help
=
'Relative or absolute path to directory'
,
default
=
'.'
,
nargs
=
'?'
)
# LS
parser_ls
=
subparsers
.
add_parser
(
'ls'
,
help
=
'Directory listing with basic
stats
(e.g. size)'
)
parser_ls
=
subparsers
.
add_parser
(
'ls'
,
help
=
'Directory listing with basic
information
(e.g. size)'
)
parser_ls
.
add_argument
(
'path'
,
help
=
'Relative or absolute path to directory'
,
default
=
'.'
,
nargs
=
'?'
)
...
...
dataman/dataman_cli.py
deleted
100644 → 0
View file @
8308bfa4
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from
__future__
import
print_function
import
sys
import
logging
import
cmd
from
dataman.lib.constants
import
LOG_LEVEL_VERBOSE
class
DataMan
(
cmd
.
Cmd
):
"""Command line tool for quick data documentation."""
prompt
=
"dm> "
intro
=
"Data Manager
\n
"
def
preloop
(
self
):
self
.
log
=
logging
.
getLogger
(
__name__
)
self
.
log
.
debug
(
"starting DataMan CLI"
)
# process command line arguments etc.
def
do_greet
(
self
,
user
):
"""greet [user name]
Simple user greeting. When used in combination with a parameter, will
respond with personalized greeting. Yay."""
if
user
:
print
(
"hello "
,
user
)
else
:
print
(
"hi there!"
)
def
do_ls
(
self
,
path
):
if
not
len
(
path
):
path
=
'.'
import
dataman.lib.dirstats
as
ds
ds
.
print_table
(
ds
.
gather
(
path
))
def
do_stats
(
self
,
path
):
if
not
len
(
path
):
path
=
'.'
import
dataman.lib.dirstats
as
ds
ds
.
print_table
(
ds
.
gather
(
path
))
def
do_vis
(
self
,
path
):
from
dataman.vis
import
vis
vis
.
run
(
target
=
path
)
def
do_exit
(
self
,
line
):
"Exit"
return
True
def
do_EOF
(
self
,
line
):
"Exit"
return
True
def
postloop
(
self
):
print
(
"Done."
)
if
__name__
==
"__main__"
:
logging
.
addLevelName
(
LOG_LEVEL_VERBOSE
,
"VERBOSE"
)
logging
.
basicConfig
(
level
=
logging
.
DEBUG
,
format
=
'%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
log
=
logging
.
getLogger
(
__name__
)
if
len
(
sys
.
argv
)
>
1
:
DataMan
().
onecmd
(
' '
.
join
(
sys
.
argv
[
1
:]))
else
:
try
:
dm
=
DataMan
().
cmdloop
()
except
KeyboardInterrupt
:
pass
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment