OCR: small adjustments for Windows

This commit is contained in:
Jean-Francois Dockes
2020-02-28 09:22:03 +01:00
parent 34a20e561a
commit 1fb9421163
3 changed files with 37 additions and 13 deletions
+10 -10
View File
@@ -195,22 +195,22 @@ class ConfTree(ConfSimple):
raise TypeError("getbin: parameters must be binary not unicode")
#_debug("ConfTree::getbin: nm [%s] sk [%s]" % (nm, sk))
if sk == b'' or sk[0] != b'/'[0]:
# Note the test for root. There does not seem to be a direct
# way to do this in os.path
if not sk:
return ConfSimple.getbin(self, nm, sk)
if sk[len(sk)-1] == b'/'[0]:
sk = sk[:len(sk)-1]
# Try all sk ancestors as submaps (/a/b/c-> /a/b/c, /a/b, /a, b'')
while sk:
while True:
if sk in self.submaps:
return ConfSimple.getbin(self, nm, sk)
if sk + b'/' in self.submaps:
return ConfSimple.getbin(self, nm, sk+b'/')
i = sk.rfind(b'/')
if i == -1:
break
sk = sk[:i]
return ConfSimple.getbin(self, nm, sk + b'/')
nsk = os.path.dirname(sk)
if nsk == sk:
# sk was already root, we're done.
break;
sk = nsk
return ConfSimple.getbin(self, nm)