12
12
import re
13
13
from functools import total_ordering
14
14
import sys
15
+ from pathlib import PureWindowsPath
16
+ import os
15
17
16
18
def get_renamer (filename ):
17
19
layout = load (filename )
18
20
def rename (path ):
19
21
renamed = layout .artificial_path (path )
20
22
return path if renamed is None else renamed
23
+ if os .name == "nt" :
24
+ return lambda path : rename (PureWindowsPath (path ).as_posix ())
21
25
return rename
22
26
23
27
def load (filename ):
@@ -257,7 +261,7 @@ def __init__(self, path, line, virtual=None):
257
261
exclude = path
258
262
self ._line = line ;
259
263
self ._original = u'-' + exclude ;
260
- if not exclude .startswith (u"/" ):
264
+ if os . name != 'nt' and not exclude .startswith (u"/" ):
261
265
exclude = u'/' + exclude
262
266
if exclude .find (u"//" ) != - 1 :
263
267
raise _error (u"Illegal '//' in exclude path" , line )
@@ -274,14 +278,14 @@ def __init__(self, path, line, virtual=None):
274
278
include = path
275
279
self ._line = line ;
276
280
self ._original = include ;
277
- if not include .startswith (u"/" ):
281
+ if os . name != 'nt' and not include .startswith (u"/" ):
278
282
include = u'/' + include
279
283
doubleslash = include .find (u"//" )
280
284
if doubleslash != include .find (u"//" ):
281
285
raise _error (u"More than one '//' in include path (project-layout)" , line )
282
286
if self ._verify_stars .match (include ):
283
287
raise _error (u"Illegal use of '**' in include path (project-layout)" , line )
284
- if not virtual .startswith (u"/" ):
288
+ if os . name != 'nt' and not virtual .startswith (u"/" ):
285
289
virtual = u"/" + virtual
286
290
if virtual .endswith (u"/" ):
287
291
virtual = virtual [0 : - 1 ]
0 commit comments