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
be124ef2
Commit
be124ef2
authored
Aug 22, 2015
by
Ronny Eichler
Browse files
Externalise CLI
parent
a03ea2a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
dataman/dataman.py
View file @
be124ef2
...
...
@@ -7,44 +7,12 @@ import cmd
import
tools
import
logging
from
constants
import
LOG_LEVEL_VERBOSE
from
dataman_cli
import
DataMan
__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
--Ronny's way of avoiding having to stare at spreadsheets."
def
preloop
(
self
):
pass
# 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_stats
(
self
,
path
):
if
not
len
(
path
):
path
=
'.'
import
folderstats
as
fs
fs
.
print_table
(
fs
.
gather
(
path
))
def
do_EOF
(
self
,
line
):
"Exit"
return
True
def
postloop
(
self
):
print
(
"Done."
)
if
__name__
==
"__main__"
:
# Command line parsing
import
argparse
...
...
dataman/dataman_cli.py
0 → 100644
View file @
be124ef2
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import
sys
import
logging
import
tools
import
cmd
from
constants
import
LOG_LEVEL_VERBOSE
class
DataMan
(
cmd
.
Cmd
):
"""Command line tool for quick data documentation."""
prompt
=
"dm> "
intro
=
"Data Manager
\n
--Ronny's way of avoiding having to stare at spreadsheets."
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_stats
(
self
,
path
):
if
not
len
(
path
):
path
=
'.'
import
folderstats
as
fs
fs
.
print_table
(
fs
.
gather
(
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
:
DataMan
().
cmdloop
()
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