equal
deleted
inserted
replaced
19 |
19 |
20 __docformat__ = "restructuredtext en" |
20 __docformat__ = "restructuredtext en" |
21 _ = unicode |
21 _ = unicode |
22 |
22 |
23 import os |
23 import os |
24 from os.path import join, exists, split |
24 from os.path import join, exists, split, isdir |
25 from warnings import warn |
25 from warnings import warn |
26 |
26 |
27 from logilab.common.decorators import cached |
27 from logilab.common.decorators import cached |
28 from logilab.common.deprecation import deprecated |
28 from logilab.common.deprecation import deprecated |
29 |
29 |
406 def static_file_open(self, rpath, mode='wb'): |
406 def static_file_open(self, rpath, mode='wb'): |
407 staticdir = self.static_directory |
407 staticdir = self.static_directory |
408 rdir, filename = split(rpath) |
408 rdir, filename = split(rpath) |
409 if rdir: |
409 if rdir: |
410 staticdir = join(staticdir, rdir) |
410 staticdir = join(staticdir, rdir) |
411 os.makedirs(staticdir) |
411 if not isdir(staticdir) and 'w' in mode: |
|
412 os.makedirs(staticdir) |
412 return file(join(staticdir, filename), mode) |
413 return file(join(staticdir, filename), mode) |
413 |
414 |
414 def static_file_add(self, rpath, data): |
415 def static_file_add(self, rpath, data): |
415 stream = self.static_file_open(rpath) |
416 stream = self.static_file_open(rpath) |
416 stream.write(data) |
417 stream.write(data) |