@@ -54,20 +54,11 @@ class _Flavour(object):
5454class _WindowsFlavour (_Flavour ):
5555 # Reference for Windows paths can be found at
5656 # http://msdn.microsoft.com/en-us/library/aa365247%28v=vs.85%29.aspx
57-
58- def casefold (self , s ):
59- return s .lower ()
60-
61- def casefold_parts (self , parts ):
62- return [p .lower () for p in parts ]
57+ pass
6358
6459
6560class _PosixFlavour (_Flavour ):
66- def casefold (self , s ):
67- return s
68-
69- def casefold_parts (self , parts ):
70- return parts
61+ pass
7162
7263
7364_windows_flavour = _WindowsFlavour ()
@@ -465,14 +456,26 @@ def _join_parsed_parts(self, drv, root, parts, drv2, root2, parts2):
465456 if not drv2 and drv :
466457 return drv , root2 , [drv + root2 ] + parts2 [1 :]
467458 elif drv2 :
468- if drv2 == drv or self ._flavour . casefold (drv2 ) == self ._flavour . casefold (drv ):
459+ if drv2 == drv or self ._casefold (drv2 ) == self ._casefold (drv ):
469460 # Same drive => second path is relative to the first
470461 return drv , root , parts + parts2 [1 :]
471462 else :
472463 # Second path is non-anchored (common case)
473464 return drv , root , parts + parts2
474465 return drv2 , root2 , parts2
475466
467+ @classmethod
468+ def _casefold (cls , s ):
469+ if cls ._case_insensitive :
470+ return s .lower ()
471+ return s
472+
473+ @classmethod
474+ def _casefold_parts (cls , parts ):
475+ if cls ._case_insensitive :
476+ return [p .lower () for p in parts ]
477+ return parts
478+
476479 def __str__ (self ):
477480 """Return the string representation of the path, suitable for
478481 passing to system calls."""
@@ -509,7 +512,7 @@ def _cparts(self):
509512 try :
510513 return self ._cached_cparts
511514 except AttributeError :
512- self ._cached_cparts = self ._flavour . casefold_parts (self ._parts )
515+ self ._cached_cparts = self ._casefold_parts (self ._parts )
513516 return self ._cached_cparts
514517
515518 def __eq__ (self , other ):
@@ -665,7 +668,7 @@ def relative_to(self, *other):
665668 else :
666669 to_abs_parts = to_parts
667670 n = len (to_abs_parts )
668- cf = self ._flavour . casefold_parts
671+ cf = self ._casefold_parts
669672 if (root or drv ) if n == 0 else cf (abs_parts [:n ]) != cf (to_abs_parts ):
670673 formatted = self ._format_parsed_parts (to_drv , to_root , to_parts )
671674 raise ValueError ("{!r} is not in the subpath of {!r}"
@@ -744,7 +747,7 @@ def match(self, path_pattern):
744747 """
745748 Return True if this path matches the given pattern.
746749 """
747- cf = self ._flavour . casefold
750+ cf = self ._casefold
748751 path_pattern = cf (path_pattern )
749752 drv , root , pat_parts = self ._parse_parts ((path_pattern ,))
750753 if not pat_parts :
0 commit comments