Renamed url to urlstring.

This commit is contained in:
Antoni Boucher 2015-08-08 13:32:04 -04:00
parent 2be0743378
commit ec5049f801

View File

@ -26,16 +26,16 @@ import qutebrowser
from qutebrowser.utils import jinja from qutebrowser.utils import jinja
def dirbrowser(url): def dirbrowser(urlstring):
"""Get the directory browser web page. """Get the directory browser web page.
Args: Args:
url: The directory path. urlstring: The directory path.
Return: Return:
The HTML of the web page. The HTML of the web page.
""" """
title = "Browse directory: {}".format(url) title = "Browse directory: {}".format(urlstring)
template = jinja.env.get_template('dirbrowser.html') template = jinja.env.get_template('dirbrowser.html')
# pylint: disable=no-member # pylint: disable=no-member
# https://bitbucket.org/logilab/pylint/issue/490/ # https://bitbucket.org/logilab/pylint/issue/490/
@ -46,23 +46,23 @@ def dirbrowser(url):
'img/file.png') 'img/file.png')
def is_file(file): def is_file(file):
return os.path.isfile(os.path.join(url, file)) return os.path.isfile(os.path.join(urlstring, file))
def is_dir(file): def is_dir(file):
return os.path.isdir(os.path.join(url, file)) return os.path.isdir(os.path.join(urlstring, file))
if os.path.dirname(url) == url: if os.path.dirname(urlstring) == urlstring:
parent = None parent = None
else: else:
parent = os.path.dirname(url) parent = os.path.dirname(urlstring)
all_files = os.listdir(url) all_files = os.listdir(urlstring)
files = sorted([{'name': file, 'absname': os.path.join(url, file)} files = sorted([{'name': file, 'absname': os.path.join(urlstring, file)}
for file in all_files if is_file(file)], for file in all_files if is_file(file)],
key=lambda v: v['name'].lower()) key=lambda v: v['name'].lower())
directories = sorted([{'name': file, 'absname': os.path.join(url, file)} directories = sorted([{'name': file, 'absname': os.path.join(urlstring, file)}
for file in all_files if is_dir(file)], for file in all_files if is_dir(file)],
key=lambda v: v['name'].lower()) key=lambda v: v['name'].lower())
html = template.render(title=title, url=url, icon='', parent=parent, html = template.render(title=title, url=urlstring, icon='', parent=parent,
files=files, directories=directories, folder=folder, files=files, directories=directories, folder=folder,
file=file) file=file)
return html return html