projects
/
zzz-pokedex.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of git@veekun.com:pokedex into HEAD
[zzz-pokedex.git]
/
pokedex
/
__init__.py
diff --git
a/pokedex/__init__.py
b/pokedex/__init__.py
index
89ad673
..
8437ce4
100644
(file)
--- a/
pokedex/__init__.py
+++ b/
pokedex/__init__.py
@@
-15,14
+15,14
@@
def main():
args = sys.argv[2:]
# Find the command as a function in this file
args = sys.argv[2:]
# Find the command as a function in this file
- func = globals().get(command, None)
- if func
and callable(func) and command != 'main'
:
+ func = globals().get(
"command_%s" %
command, None)
+ if func:
func(*args)
else:
func(*args)
else:
- help()
+
command_
help()
-def csvimport(engine_uri, directory='.'):
+def c
ommand_c
svimport(engine_uri, directory='.'):
import csv
from sqlalchemy.orm.attributes import instrumentation_registry
import csv
from sqlalchemy.orm.attributes import instrumentation_registry
@@
-129,7
+129,7
@@
def csvimport(engine_uri, directory='.'):
else:
print 'loaded'
else:
print 'loaded'
-def csvexport(engine_uri, directory='.'):
+def c
ommand_c
svexport(engine_uri, directory='.'):
import csv
session = connect(engine_uri)
import csv
session = connect(engine_uri)
@@
-142,7
+142,8
@@
def csvexport(engine_uri, directory='.'):
columns = [col.name for col in table.columns]
writer.writerow(columns)
columns = [col.name for col in table.columns]
writer.writerow(columns)
- for row in session.query(table).all():
+ primary_key = table.primary_key
+ for row in session.query(table).order_by(*primary_key).all():
csvs = []
for col in columns:
# Convert Pythony values to something more universal
csvs = []
for col in columns:
# Convert Pythony values to something more universal
@@
-160,7
+161,7
@@
def csvexport(engine_uri, directory='.'):
writer.writerow(csvs)
writer.writerow(csvs)
-def lookup(engine_uri, name):
+def
command_
lookup(engine_uri, name):
# XXX don't require uri! somehow
session = connect(engine_uri)
# XXX don't require uri! somehow
session = connect(engine_uri)
@@
-174,7
+175,7
@@
def lookup(engine_uri, name):
print object.__tablename__, object.name
print object.__tablename__, object.name
-def help():
+def
command_
help():
print u"""pokedex -- a command-line Pokédex interface
help Displays this message.
print u"""pokedex -- a command-line Pokédex interface
help Displays this message.