Skip to content

Commit

Permalink
Defer sub-command imports until usage
Browse files Browse the repository at this point in the history
This way, if you're not using those modules, you won't waste time loading them.
  • Loading branch information
kfsone committed Nov 2, 2014
1 parent 2d338d5 commit bb6b8e5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions commands/TEMPLATE.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from commands.commandenv import ResultRow
from commands import MutuallyExclusiveGroup, ParseArgument
from formatting import RowFormat, ColumnFormat

######################################################################
# Parser config
Expand Down Expand Up @@ -28,6 +26,7 @@
# Perform query and populate result set

def run(results, cmdenv, tdb):
from commands.commandenv import ResultRow

### TODO: Implement

Expand All @@ -37,4 +36,6 @@ def run(results, cmdenv, tdb):
# Transform result set into output

def render(results, cmdenv, tdb):
from formatting import RowFormat, ColumnFormat

### TODO: Implement
6 changes: 4 additions & 2 deletions commands/local_cmd.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from commands.commandenv import ResultRow
from commands import MutuallyExclusiveGroup, ParseArgument
from formatting import RowFormat, ColumnFormat

######################################################################
# Parser config
Expand Down Expand Up @@ -78,6 +76,8 @@ def distance(self, star):
# Perform query and populate result set

def run(results, cmdenv, tdb):
from commands.commandenv import ResultRow

cmdenv = results.cmdenv
tdb = cmdenv.tdb
srcSystem = cmdenv.nearSystem
Expand Down Expand Up @@ -124,6 +124,8 @@ def run(results, cmdenv, tdb):
# Transform result set into output

def render(results, cmdenv, tdb):
from formatting import RowFormat, ColumnFormat

# Compare system names so we can tell
longestNamed = max(results.rows,
key=lambda row: len(row.system.name()))
Expand Down
5 changes: 3 additions & 2 deletions commands/nav_cmd.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from commands.commandenv import ResultRow
from commands import MutuallyExclusiveGroup, ParseArgument
from formatting import RowFormat, ColumnFormat

######################################################################
# Parser config
Expand Down Expand Up @@ -40,6 +38,7 @@
# Perform query and populate result set

def run(results, cmdenv, tdb):
from commands.commandenv import ResultRow

### TODO: Implement

Expand All @@ -49,6 +48,8 @@ def run(results, cmdenv, tdb):
# Transform result set into output

def render(results, cmdenv, tdb):
from formatting import RowFormat, ColumnFormat

### TODO: Implement

def navCommand(tdb, cmdenv):
Expand Down

0 comments on commit bb6b8e5

Please sign in to comment.