Commits

"Jas...@ubib.eur.nl>"  committed 4abff46

got mods working

  • Participants
  • Parent commits 214cc47

Comments (0)

Files changed (4)

File moai/example.py

-import os
-import time
-from datetime import datetime
 
 from lxml import etree
 
         self.id = 'oai:example-%s' % id
         self.modified = xpath.date('//x:modified')
         self.deleted = False
-        
+
+        author_data = []
+        for num, el in enumerate(xpath('//x:author'), 1):
+            first = xpath.string('//x:author[%d]/x:givenName' % num)
+            sur = xpath.string('//x:author[%d]/x:familyName' % num)
+            name = u'%s %s' % (first, sur)
+            author_data.append({'name': [name],
+                                'surname': [sur],
+                                'firstname': [first],
+                                'role': [u'aut']})
+
+        self.data = {'identifier': [u'http://example.org/data/%s' % id],
+                     'title': [xpath.string('//x:title')],
+                     'subject': xpath.strings('//x:subject'),
+                     'description': [xpath.string('//x:abstract')],
+                     'creator': [d['name'] for d in author_data],
+                     'author_data': author_data,
+                     'language': [u'en'],
+                     'date': [xpath.string('//x:issued')]}
+
         self.sets = {u'example': {u'name':u'example',
                                   u'description':u'An Example Set'}}
 
         if access == 'public':
             self.sets[u'public'] = {u'name':u'public',
                                     u'description':u'Public access'}
+            self.data['rights'] = [u'open access']
         elif access == 'private':
             self.sets[u'private'] = {u'name':u'private',
                                      u'description':u'Private access'}
+            self.data['rights'] = [u'restricted access']
 
-        self.data = {'identifier': [u'http://example.org/data/%s' % id],
-                     'title': [xpath.string('//x:title')],
-                     'subject': xpath.strings('//x:subject'),
-                     'description': [xpath.string('//x:abstract')],
-                     'date': [xpath.string('//x:issued')]}

File moai/metadata.py

 
 from lxml.builder import ElementMaker
-import simplejson
 
 XSI_NS = 'http://www.w3.org/2001/XMLSchema-instance'
   
                 contributor_data.append(contributor)
 
             if data['metadata'].get('%s_data' % ctype):
-                contributor_data = [simplejson.loads(s) for s in data[
-                    'metadata']['%s_data' % ctype]]
+                contributor_data = [s for s in data['metadata'][
+                    '%s_data' % ctype]]
         
             if not contributor_data:            
                 contributor_data = [{'name':[a]} for a in data[

File moai/tools.py

 import sys
 import os
 import time
-import logging
-import logging.handlers
 import datetime
 import pkg_resources
 from pkg_resources import iter_entry_points

File moai/utils.py

 import sys
-import os
 import datetime
 import time
 import logging
-from ConfigParser import ConfigParser
+import logging.handlers
 
 def get_moai_log():
     log = logging.getLogger('moai')
     log.setLevel(logging.DEBUG)
     handler = logging.handlers.RotatingFileHandler('moai.log')
-    handler.setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s"))
+    handler.setFormatter(logging.Formatter(
+        "%(asctime)s - %(name)s - %(levelname)s - %(message)s"))
     log.addHandler(handler)
     return log
 
-def parse_config_file(filename, section):
-    config = ConfigParser()
-    config.read(filename)
-
-    buildout_dir = os.path.dirname(filename)
-
-    if not section in config.sections():
-        return {}
-    result = {}
-    for option in config.options(section):
-        value = config.get(section, option)
-        result[option] = value.replace('${buildout:directory}',
-                                       buildout_dir)
-    return result
-
 def get_duration(starttime):
-    h,m,s = time.asctime(time.gmtime(time.time() - starttime)).split(' ')[-2].split(':')
+    h,m,s = time.asctime(
+        time.gmtime(time.time() - starttime)).split(' ')[-2].split(':')
     s = int(s)
     m = int(m)
     h = int(h)