@@ -27,7 +27,7 @@ def main():
27
27
help = 'Default output filename.' )
28
28
parser .add_argument ('--print' , '-P' , action = 'store_true' , default = False , help = 'Whether to print to stdout.' )
29
29
parser .add_argument ('--depth' , '-d' , type = int , default = 0 , help = 'Set cutoff depth.' )
30
- parser .add_argument ('--root' , '-r' , type = str , default = '/' , help = 'Set base root dir.' )
30
+ parser .add_argument ('--root' , '-r' , type = str , default = os . path . sep , help = 'Set base root dir.' )
31
31
parser .add_argument ('--human' , action = 'store_true' , default = False , help = 'Make size human readable.' )
32
32
parser .add_argument ('path' , type = str , default = '' , help = 'Path' , nargs = '?' )
33
33
arguments = parser .parse_args ()
@@ -60,7 +60,7 @@ def app(args):
60
60
template = os .path .abspath (args .template ) if args .template else '' )
61
61
62
62
63
- def generate_once (theme , root , files , name , if_print , base = '/' , human = False , template = '' ):
63
+ def generate_once (theme , root , files , name , if_print , base = os . path . sep , human = False , template = '' ):
64
64
if not template :
65
65
environment = jinja2 .Environment (
66
66
loader = jinja2 .PackageLoader ('index_generator' , 'templates/' + theme ),
@@ -89,7 +89,7 @@ def generate_once(theme, root, files, name, if_print, base='/', human=False, tem
89
89
'isDir' : entry .isDir
90
90
})
91
91
html = template .render (ig = {
92
- 'root' : base + root .lstrip ('.*/' ),
92
+ 'root' : base + root .lstrip ('.*' + os . path . sep ),
93
93
'files' : filelist ,
94
94
'generator' : {
95
95
'name' : APP_NAME ,
@@ -105,7 +105,7 @@ def generate_once(theme, root, files, name, if_print, base='/', human=False, tem
105
105
print (html , file = f )
106
106
107
107
108
- def generate_recursively (theme , path , name , if_print , max_depth = 0 , base = '/' , human = False , template = '' ):
108
+ def generate_recursively (theme , path , name , if_print , max_depth = 0 , base = os . path . sep , human = False , template = '' ):
109
109
os .chdir (path )
110
110
for root , dirs , files in os .walk ('.' ):
111
111
if max_depth != 0 and root .count (os .sep ) >= max_depth :
0 commit comments