From 024550e9a9945b82596041fc72cc01104bde5651 Mon Sep 17 00:00:00 2001 From: Ken Lauer Date: Mon, 31 Jul 2023 10:29:03 -0700 Subject: [PATCH] FIX: win32 file:/ prefix for lxml doc URL --- blark/solution.py | 6 +++++- blark/util.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/blark/solution.py b/blark/solution.py index 450f248..2883206 100644 --- a/blark/solution.py +++ b/blark/solution.py @@ -179,7 +179,11 @@ def filename_from_xml(xml: Optional[lxml.etree.Element]) -> Optional[pathlib.Pat if root.docinfo.URL is None: return None - return pathlib.Path(root.docinfo.URL) + url = str(root.docinfo.URL) + if url.startswith("file:/"): + # Note: this only seems to be necessary on Windows and I'm not entirely sure why + url = url[len("file:/"):] + return pathlib.Path(url) def get_child_text( diff --git a/blark/util.py b/blark/util.py index 674e2fc..2ee4502 100644 --- a/blark/util.py +++ b/blark/util.py @@ -4,6 +4,7 @@ import dataclasses import enum import hashlib +import os import pathlib import re from typing import Any, Dict, Generator, List, Optional, Set, Tuple, TypeVar @@ -522,7 +523,7 @@ def fix_case_insensitive_path(path: AnyPath) -> pathlib.Path: part = all_files[part.lower()] except KeyError: raise FileNotFoundError( - f"Path does not exist:\n" f"{path}\n{new_path}/{part} missing" + f"Path does not exist: {path}\n{new_path}{os.pathsep}{part} missing" ) from None new_path = new_path / part return new_path.resolve()