@@ -52,13 +52,18 @@ def isidentifier(s):
52
52
53
53
StringIO = io .StringIO
54
54
55
+ if hasattr (os , "fspath" ): # PY3
56
+ fspath = os .fspath
57
+ else : # PY2
58
+ fspath = str
59
+
55
60
56
61
class Rule :
57
62
"""A single set of rules for 'unasync'ing file(s)"""
58
63
59
64
def __init__ (self , fromdir , todir , additional_replacements = None ):
60
- self .fromdir = fromdir .replace ("/" , os .sep )
61
- self .todir = todir .replace ("/" , os .sep )
65
+ self .fromdir = fspath ( fromdir ) .replace ("/" , os .sep )
66
+ self .todir = fspath ( todir ) .replace ("/" , os .sep )
62
67
63
68
# Add any additional user-defined token replacements to our list.
64
69
self .token_replacements = _ASYNC_TO_SYNC .copy ()
@@ -69,6 +74,8 @@ def _match(self, filepath):
69
74
"""Determines if a Rule matches a given filepath and if so
70
75
returns a higher comparable value if the match is more specific.
71
76
"""
77
+ filepath = fspath (filepath )
78
+
72
79
file_segments = [x for x in filepath .split (os .sep ) if x ]
73
80
from_segments = [x for x in self .fromdir .split (os .sep ) if x ]
74
81
len_from_segments = len (from_segments )
@@ -83,6 +90,7 @@ def _match(self, filepath):
83
90
return False
84
91
85
92
def _unasync_file (self , filepath ):
93
+ filepath = fspath (filepath )
86
94
with open (filepath , "rb" ) as f :
87
95
write_kwargs = {}
88
96
if sys .version_info [0 ] >= 3 : # PY3 # pragma: no branch
0 commit comments