1
0
Fork 0
forked from github/pelican

fix testing failures

when settings could be pathlib.Path
This commit is contained in:
MinchinWeb 2020-04-23 13:47:10 -06:00
commit cfba3d72be
6 changed files with 58 additions and 39 deletions

View file

@ -3,6 +3,7 @@ import fnmatch
import locale
import logging
import os
import pathlib
import re
import shutil
import sys
@ -921,17 +922,28 @@ def split_all(path):
>>> split_all(os.path.join('a', 'b', 'c'))
['a', 'b', 'c']
"""
components = []
path = path.lstrip('/')
while path:
head, tail = os.path.split(path)
if tail:
components.insert(0, tail)
elif head == path:
components.insert(0, head)
break
path = head
return components
if isinstance(path, str):
components = []
path = path.lstrip('/')
while path:
head, tail = os.path.split(path)
if tail:
components.insert(0, tail)
elif head == path:
components.insert(0, head)
break
path = head
return components
elif isinstance(path, pathlib.Path):
return path.parts
elif path is None:
return None
else:
raise TypeError(
'"path" was {}, must be string, None, or pathlib.Path'.format(
type(path)
)
)
def is_selected_for_writing(settings, path):