125 @type bool (optional) |
126 @type bool (optional) |
126 @return translated filename |
127 @return translated filename |
127 @rtype str |
128 @rtype str |
128 """ |
129 """ |
129 if remote2local: |
130 if remote2local: |
130 path = fn.replace(self.translateRemote, self.translateLocal) |
131 path = ( |
|
132 re.sub( |
|
133 f"^{re.escape(self.translateRemote)}", |
|
134 self.translateLocal, |
|
135 fn, |
|
136 flags=re.IGNORECASE, |
|
137 ) |
|
138 if self.translateRemoteWindows |
|
139 else fn.replace(self.translateRemote, self.translateLocal) |
|
140 ) |
131 if self.translateLocalWindows: |
141 if self.translateLocalWindows: |
132 path = path.replace("/", "\\") |
142 path = path.replace("/", "\\") |
133 else: |
143 else: |
134 path = fn.replace(self.translateLocal, self.translateRemote) |
144 path = ( |
|
145 re.sub( |
|
146 f"^{re.escape(self.translateLocal)}", |
|
147 self.translateRemote, |
|
148 fn, |
|
149 flags=re.IGNORECASE, |
|
150 ) |
|
151 if self.translateLocalWindows |
|
152 else fn.replace(self.translateLocal, self.translateRemote) |
|
153 ) |
135 if not self.translateRemoteWindows: |
154 if not self.translateRemoteWindows: |
136 path = path.replace("\\", "/") |
155 path = path.replace("\\", "/") |
137 |
156 |
138 return path |
157 return path |
139 |
158 |