1. Alessio Deiana
  2. invenio-devserver

Commits

Alessio Deiana  committed aa6d456

Improves handling of invenio destination paths

We now handle way better file copying for plugins and html templates.

  • Participants
  • Parent commits c6206aa
  • Branches master

Comments (0)

Files changed (3)

File setup.py

View file
 
 setup(
     name='invenio-devserver',
-    version='0.7',
+    version='0.8',
     packages=find_packages('src'),
     package_dir={'': 'src'},
     include_package_data=False,

File src/invenio_devserver/config.py

View file
 site-packages.
 """
 import os
+import re
 
 # Check if CFG_INVENIO_SRC is set otherwise use default.
 if 'CFG_INVENIO_SRCDIR' in os.environ:
     'conf': 'etc',
     'bft': 'etc/bibformat/format_templates',
     'bfo': 'etc/bibformat/output_formats',
+    'html': None,
 }
 
+SPECIAL_DIRS = {
+    ur"^modules/(?P<module>[a-z]+)/etc/templates/.+\.html": 'etc/%(module)s/templates/',
+    ur"^modules/bibformat/lib/elements/.+\.py": 'lib/python/invenio/bibformat_elements',
+    ur"^bibformat/format_elements/.+\.py": 'lib/python/invenio/bibformat_elements',
+    ur"^modules/webjournal/lib/elements/.+\.py": 'lib/python/invenio/bibformat_elements',
+    ur"^modules/bibcheck/lib/plugins/.+\.py": 'lib/python/invenio/bibcheck_plugins',
+    ur"^modules/webstyle/lib/goto_plugins/.+\.py": 'lib/python/invenio/goto_plugins',
+    ur"^modules/websubmit/lib/functions/.+\.py": 'lib/python/invenio/websubmit_functions',
+    ur"^modules/miscutil/lib/upgrades/.+\.py": 'lib/python/invenio/upgrades',
+    ur"^modules/bibindex/lib/tokenizers/.+\.py": 'lib/python/invenio/bibindex_tokenizers',
+    ur"^modules/bibfield/lib/functions/.+\.py": 'lib/python/invenio/bibfield_functions',
+}
+
+SPECIAL_DIRS_RE = {re.compile(pattern , re.U|re.I): dest_dir for pattern, dest_dir in SPECIAL_DIRS.iteritems()}
+
 STATIC_FILES = {
     '/img': '/var/www/img',
     '/js': '/var/www/js',

File src/invenio_devserver/serve.py

View file
 
 DESCRIPTION = "Invenio web server for development"
 USAGE_MESSAGE = "python serve.py [-bp]"
-RE_BIBFORMAT_ELEMENTS = re.compile(ur"^(/modules/bibformat/lib/elements/.+\.py|/bibformat/format_elements/.+\.py)",
-                                   re.U|re.I)
 
 
 def get_extension(filename):
     rel_path = filename
     for src_path in config.SRC_PATH:
         if rel_path.startswith(src_path):
-            rel_path = rel_path.replace(src_path, '')
+            rel_path = rel_path.replace('%s/' % src_path, '')
             break
 
     ext = get_extension(filename)
     lib_dir = dests[ext]
+
+    for regexp, dest_dir in config.SPECIAL_DIRS_RE.iteritems():
+        m = regexp.match(rel_path)
+        if m:
+            lib_dir = dest_dir % m.groupdict()
+            break
+
     if lib_dir:
-        if ext == 'py':
-            if RE_BIBFORMAT_ELEMENTS.match(rel_path):
-                lib_dir = os.path.join(lib_dir, 'bibformat_elements')
         dest = os.path.join(install_path,
                             lib_dir,
                             os.path.basename(filename))
+
     return dest
 
 
             if old_time is None:
                 mtimes[filename] = mtime
                 dest = select_destination_path(filename)
-                if os.path.isfile(dest):
+                if dest and os.path.isfile(dest):
                     old_time = os.stat(dest).st_mtime
                 else:
                     old_time = mtime