Skip to content

Commit

Permalink
compatibility with doit v0.28.0
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Apr 11, 2015
1 parent 6c8b559 commit fb19e2d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -4,6 +4,7 @@ New in master
Features
--------

* Compatibility with doit v0.28.0 (Issue #1655)
* Add reStructuredText transform support (Issue #1647)
* Produce Unicode output in ``nikola init`` (via Issue #1644)
* Add ``HIDDEN_TAGS`` and ``HIDDEN_CATEGORIES`` settings to hide some
Expand Down
14 changes: 8 additions & 6 deletions nikola/__main__.py
Expand Up @@ -172,8 +172,9 @@ def print_usage(cmds):

print("Nikola is a tool to create static websites and blogs. For full documentation and more information, please visit http://getnikola.com/\n\n")
print("Available commands:")
for cmd in sorted(cmds.values(), key=attrgetter('name')):
print(" nikola %-*s %s" % (20, cmd.name, cmd.doc_purpose))
for cmd_name in sorted(cmds.keys()):
cmd = cmds[cmd_name]
print(" nikola {:20s} {}".format(cmd_name, cmd.doc_purpose))
print("")
print(" nikola help show help / reference")
print(" nikola help <command> show command usage")
Expand Down Expand Up @@ -265,20 +266,21 @@ class DoitNikola(DoitMain):
TASK_LOADER = NikolaTaskLoader

def __init__(self, nikola, quiet=False):
super(DoitNikola, self).__init__()
self.nikola = nikola
nikola.doit = self
self.task_loader = self.TASK_LOADER(nikola, quiet)

def get_commands(self):
def get_cmds(self):
# core doit commands
cmds = DoitMain.get_commands(self)
cmds = DoitMain.get_cmds(self)
# load nikola commands
for name, cmd in self.nikola._commands.items():
cmds[name] = cmd
return cmds

def run(self, cmd_args):
sub_cmds = self.get_commands()
sub_cmds = self.get_cmds()
args = self.process_args(cmd_args)
args = [sys_decode(arg) for arg in args]

Expand Down Expand Up @@ -306,7 +308,7 @@ def run(self, cmd_args):
if args[0] not in sub_cmds.keys():
LOGGER.error("Unknown command {0}".format(args[0]))
return 3
if not isinstance(sub_cmds[args[0]], (Command, Help)): # Is a doit command
if sub_cmds[args[0]] is not Help and not isinstance(sub_cmds[args[0]], Command): # Is a doit command
if not self.nikola.configured:
LOGGER.error("This command needs to run inside an "
"existing Nikola site.")
Expand Down
7 changes: 5 additions & 2 deletions nikola/plugin_categories.py
Expand Up @@ -80,7 +80,7 @@ class Command(BasePlugin, DoitCommand):
"""These plugins are exposed via the command line.
They implement the doit Command interface."""

name = "dummy_command"
name = _name = "dummy_command"

This comment has been minimized.

Copy link
@Kwpolska

Kwpolska Apr 11, 2015

Author Member

_name is unnecessary, I misunderstood how get_name() works — fixed in d2134eb


doc_purpose = "A short explanation."
doc_usage = ""
Expand All @@ -91,7 +91,10 @@ class Command(BasePlugin, DoitCommand):

def __init__(self, *args, **kwargs):
BasePlugin.__init__(self, *args, **kwargs)
DoitCommand.__init__(self)

def __call__(self, config=None, **kwargs):
DoitCommand.__init__(self, config, **kwargs)
return self

def execute(self, options=None, args=None):
"""Check if the command can run in the current environment,
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,4 +1,4 @@
doit==0.27.0
doit==0.28.0
Pygments>=1.6
Pillow>=2.4.0
python-dateutil==2.4.2
Expand Down

0 comments on commit fb19e2d

Please sign in to comment.