mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-15 20:01:03 +00:00
Make file list an iterator, and add missing slash if needed to manually given file URLs.
This commit is contained in:
parent
7862147ca3
commit
a9335fb3e8
3 changed files with 12 additions and 14 deletions
|
|
@ -115,8 +115,8 @@ def get_index_html (urls):
|
|||
"""
|
||||
Construct artificial index.html from given URLs.
|
||||
|
||||
@param urls: list with url strings
|
||||
@type urls: list of string
|
||||
@param urls: URL strings
|
||||
@type urls: iterator of string
|
||||
"""
|
||||
lines = ["<html>", "<body>"]
|
||||
for entry in urls:
|
||||
|
|
@ -127,7 +127,6 @@ def get_index_html (urls):
|
|||
return os.linesep.join(lines)
|
||||
|
||||
|
||||
|
||||
class StoringHandler (logging.Handler):
|
||||
"""Store all emitted log messages in a size-limited list.
|
||||
Used by the CSS syntax checker."""
|
||||
|
|
|
|||
|
|
@ -36,18 +36,16 @@ except ImportError:
|
|||
has_sqlite = False
|
||||
|
||||
def get_files (dirname):
|
||||
"""
|
||||
Get lists of files in directory. Does only allow regular files
|
||||
and directories, no symlinks.
|
||||
"""
|
||||
files = []
|
||||
"""Get iterator of entries in directory. Only allows regular files
|
||||
and directories, no symlinks."""
|
||||
for entry in os.listdir(dirname):
|
||||
fullentry = os.path.join(dirname, entry)
|
||||
if os.path.islink(fullentry) or \
|
||||
not (os.path.isfile(fullentry) or os.path.isdir(fullentry)):
|
||||
if os.path.islink(fullentry):
|
||||
continue
|
||||
files.append(entry)
|
||||
return files
|
||||
if os.path.isfile(fullentry):
|
||||
yield entry
|
||||
elif os.path.isdir(fullentry):
|
||||
yield entry+"/"
|
||||
|
||||
|
||||
def prepare_urlpath_for_nt (path):
|
||||
|
|
@ -107,6 +105,8 @@ class FileUrl (urlbase.UrlBase):
|
|||
base_url = os.path.expanduser(base_url)
|
||||
if not is_absolute_path(base_url):
|
||||
base_url = os.getcwd()+"/"+base_url
|
||||
if os.path.isdir(base_url):
|
||||
base_url += "/"
|
||||
base_url = "file://"+base_url
|
||||
if os.name == "nt":
|
||||
base_url = base_url.replace("\\", "/")
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
url file://%(curdir)s/%(datadir)s/dir
|
||||
url file://%(curdir)s/%(datadir)s/dir/
|
||||
cache key file://%(curdir)s/%(datadir)s/dir/
|
||||
real url file://%(curdir)s/%(datadir)s/dir/
|
||||
name %(datadir)s/dir
|
||||
warning Added trailing slash to directory.
|
||||
valid
|
||||
|
||||
url %%ED%%BB%%AD%%AF%%BF.dat
|
||||
|
|
|
|||
Loading…
Reference in a new issue