From 37c509b858cbaf2af13728c31c295a7819452dc4 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 8 Dec 2017 18:47:57 +0100 Subject: Bugfix for HTML paths on network drives --- src/bidding_data.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/bidding_data.py b/src/bidding_data.py index fa26c2a..6a41994 100644 --- a/src/bidding_data.py +++ b/src/bidding_data.py @@ -20,6 +20,14 @@ from bs4 import BeautifulSoup as bs4 __version__ = '1.1rc3' +def isfile(file_path): + """Check if a path describes a file. + + Accepts symlinks to files, and does not fail for network drivers. + """ + return path.exists(file_path) and not path.isdir(file_path) + + def hash_file(file_path, block=65536): """Return MD5 hash of a specified file.""" if path.exists(file_path): @@ -341,7 +349,7 @@ class JFRBidding(object): bidding_link['data-bidding-link'] = path.basename( bidding_path) # only append link if we've got bidding data - if path.isfile(path.join( + if isfile(path.join( path.dirname(self.__tournament_prefix), bidding_link['data-bidding-link'])): if bidding_path in self.__bidding_files: @@ -618,7 +626,7 @@ def main(): def file_path(filepath): """Sanitize and validate file paths from input parameters.""" filepath = unicode(filepath, sys.getfilesystemencoding()) - if path.isfile(filepath): + if isfile(filepath): return filepath else: argument_parser.error('File %s does not exist' % filepath) -- cgit v1.2.3