mirror of
https://github.com/moparisthebest/xeps
synced 2025-02-25 23:21:52 -05:00
checkdeadlinks: Move the checking code into its own is_dead() function.
This commit is contained in:
parent
3acdb8f2d1
commit
615d091877
@ -50,25 +50,7 @@ import urllib2
|
|||||||
|
|
||||||
from xml.dom.minidom import parse,parseString,Document
|
from xml.dom.minidom import parse,parseString,Document
|
||||||
|
|
||||||
def main():
|
def is_dead(url):
|
||||||
parser = ArgumentParser(description=__doc__)
|
|
||||||
parser.add_argument('-v', '--verbose', action='store_true', help='Enables more verbosity')
|
|
||||||
parser.add_argument('-x', '--xep', type=int, help='Defines the number of the XEP to check')
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
xepnum = '%04d' % args.xep
|
|
||||||
verbose = args.verbose
|
|
||||||
|
|
||||||
xepfile = 'xep-' + xepnum + '.xml'
|
|
||||||
thexep = parse(xepfile)
|
|
||||||
|
|
||||||
links = thexep.getElementsByTagName("link")
|
|
||||||
deadlinks = 0
|
|
||||||
if verbose:
|
|
||||||
print 'Checking XEP-' + xepnum + ':'
|
|
||||||
|
|
||||||
for link in links:
|
|
||||||
url = link.getAttribute("url")
|
|
||||||
if re.match("^(http|https)", url):
|
if re.match("^(http|https)", url):
|
||||||
if verbose:
|
if verbose:
|
||||||
print url + ' :',
|
print url + ' :',
|
||||||
@ -82,10 +64,38 @@ def main():
|
|||||||
reason = str(e)
|
reason = str(e)
|
||||||
if verbose:
|
if verbose:
|
||||||
print "XEP-" + xepnum + " - DEAD: " + url + " [" + reason + "]"
|
print "XEP-" + xepnum + " - DEAD: " + url + " [" + reason + "]"
|
||||||
deadlinks = deadlinks + 1
|
return True
|
||||||
else:
|
else:
|
||||||
if verbose:
|
if verbose:
|
||||||
print 'OK'
|
print 'OK'
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument('-v', '--verbose', action='store_true', help='Enables more verbosity')
|
||||||
|
parser.add_argument('-x', '--xep', type=int, help='Defines the number of the XEP to check')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
global xepnum
|
||||||
|
xepnum = '%04d' % args.xep
|
||||||
|
|
||||||
|
global verbose
|
||||||
|
verbose = args.verbose
|
||||||
|
|
||||||
|
xepfile = 'xep-' + xepnum + '.xml'
|
||||||
|
thexep = parse(xepfile)
|
||||||
|
|
||||||
|
links = thexep.getElementsByTagName("link")
|
||||||
|
deadlinks = 0
|
||||||
|
if verbose:
|
||||||
|
print 'Checking XEP-' + xepnum + ':'
|
||||||
|
|
||||||
|
for link in links:
|
||||||
|
url = link.getAttribute("url")
|
||||||
|
if is_dead(url):
|
||||||
|
deadlinks += 1
|
||||||
|
|
||||||
if deadlinks > 0:
|
if deadlinks > 0:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user