[library-web] [app] use shutil.copytree to copy the skin/ directory to web dir



commit a6ab91ac4c6f9fd3b14781eecf035160f207b334
Author: Frédéric Péters <fpeters 0d be>
Date:   Sat Aug 8 19:38:02 2009 +0200

    [app] use shutil.copytree to copy the skin/ directory to web dir

 src/app.py |   22 +++++-----------------
 1 files changed, 5 insertions(+), 17 deletions(-)
---
diff --git a/src/app.py b/src/app.py
index 1d65557..0f72c35 100644
--- a/src/app.py
+++ b/src/app.py
@@ -21,6 +21,7 @@ import glob
 import logging
 import os
 from optparse import OptionParser
+import shutil
 import stat
 import urllib2
 
@@ -85,10 +86,6 @@ class App:
     def copy_static_files(self):
         if not os.path.exists(os.path.join(self.config.output_dir, 'js')):
             os.makedirs(os.path.join(self.config.output_dir, 'js'))
-        if not os.path.exists(os.path.join(self.config.output_dir, 'skin')):
-            os.makedirs(os.path.join(self.config.output_dir, 'skin'))
-        if not os.path.exists(os.path.join(self.config.output_dir, 'skin/icons')):
-            os.makedirs(os.path.join(self.config.output_dir, 'skin/icons'))
 
         for src in glob.glob('%s/*.js' % self.javascript_dir):
             dst = os.path.join(self.config.output_dir, 'js', os.path.basename(src))
@@ -96,19 +93,10 @@ class App:
                     os.stat(src)[stat.ST_MTIME] > os.stat(dst)[stat.ST_MTIME]:
                 open(dst, 'w').write(open(src, 'r').read())
 
-        for src in glob.glob('%s/*.css' % self.skin_dir) + \
-                        glob.glob('%s/*.png' % self.skin_dir) + \
-                        glob.glob('%s/*.gif' % self.skin_dir):
-            dst = os.path.join(self.config.output_dir, 'skin', os.path.basename(src))
-            if not os.path.exists(dst) or \
-                    os.stat(src)[stat.ST_MTIME] > os.stat(dst)[stat.ST_MTIME]:
-                open(dst, 'w').write(open(src, 'r').read())
-
-        for src in glob.glob('%s/icons/*.png' % self.skin_dir):
-            dst = os.path.join(self.config.output_dir, 'skin/icons', os.path.basename(src))
-            if not os.path.exists(dst) or \
-                    os.stat(src)[stat.ST_MTIME] > os.stat(dst)[stat.ST_MTIME]:
-                open(dst, 'w').write(open(src, 'r').read())
+        skin_dir = os.path.join(self.config.output_dir, 'skin')
+        if os.path.exists(skin_dir):
+            shutil.rmtree(skin_dir)
+        shutil.copytree(self.skin_dir, os.path.join(self.config.output_dir, 'skin'))
 
     def download(self, url):
         parsed_url = urllib2.urlparse.urlparse(url)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]