aboutsummaryrefslogtreecommitdiffstats
path: root/nikola/plugins/command_check.py
diff options
context:
space:
mode:
authorLibravatarAgustin Henze <tin@sluc.org.ar>2013-05-30 17:41:06 -0300
committerLibravatarAgustin Henze <tin@sluc.org.ar>2013-05-30 17:41:06 -0300
commit0c4dfdec5b55b6064dccc38bbfb0a7c0699c895a (patch)
treea6707225ccc559f7edf50ddd3fdc7fc85145c921 /nikola/plugins/command_check.py
parent8b14a1e5b2ca574fdd4fd2377567ec98a110d4b6 (diff)
Imported Upstream version 5.4.4
Diffstat (limited to 'nikola/plugins/command_check.py')
-rw-r--r--nikola/plugins/command_check.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/nikola/plugins/command_check.py b/nikola/plugins/command_check.py
index a396f63..ea82703 100644
--- a/nikola/plugins/command_check.py
+++ b/nikola/plugins/command_check.py
@@ -24,6 +24,7 @@
from __future__ import print_function
import os
+import sys
try:
from urllib import unquote
from urlparse import urlparse
@@ -74,14 +75,17 @@ class CommandCheck(Command):
print(self.help())
return False
if options['links']:
- scan_links(options['find_sources'])
+ failure = scan_links(options['find_sources'])
if options['files']:
- scan_files()
+ failure = scan_files()
+ if failure:
+ sys.exit(1)
existing_targets = set([])
def analize(task, find_sources=False):
+ rv = False
try:
filename = task.split(":")[-1]
d = lxml.html.fromstring(open(filename).read())
@@ -100,6 +104,7 @@ def analize(task, find_sources=False):
if os.path.exists(target_filename):
existing_targets.add(target_filename)
else:
+ rv = True
print("Broken link in {0}: ".format(filename), target)
if find_sources:
print("Possible sources:")
@@ -109,17 +114,21 @@ def analize(task, find_sources=False):
except Exception as exc:
print("Error with:", filename, exc)
+ return rv
def scan_links(find_sources=False):
print("Checking Links:\n===============\n")
+ failure = False
for task in os.popen('nikola list --all', 'r').readlines():
task = task.strip()
if task.split(':')[0] in ('render_tags', 'render_archive',
'render_galleries', 'render_indexes',
- 'render_pages',
+ 'render_pages'
'render_site') and '.html' in task:
- analize(task, find_sources)
+ if analize(task, find_sources):
+ failure = True
+ return failure
def scan_files():
@@ -127,6 +136,7 @@ def scan_files():
task_fnames = set([])
real_fnames = set([])
# First check that all targets are generated in the right places
+ failure = False
for task in os.popen('nikola list --all', 'r').readlines():
task = task.strip()
if 'output' in task and ':' in task:
@@ -144,6 +154,7 @@ def scan_files():
print("\nFiles from unknown origins:\n")
for f in only_on_output:
print(f)
+ failure = True
only_on_input = list(task_fnames - real_fnames)
if only_on_input:
@@ -151,3 +162,5 @@ def scan_files():
print("\nFiles not generated:\n")
for f in only_on_input:
print(f)
+
+ return failure