Esempio n. 1
0
 def __init__(self, transmogrifier, name, options, previous):
     self.key = Expression(options['key'], transmogrifier, name, options)
     self.value = Expression(options['value'], transmogrifier, name,
                             options)
     self.condition = Condition(options.get('condition', 'python:True'),
                                transmogrifier, name, options)
     self.previous = previous
    def __init__(self, transmogrifier, name, options, previous):
        self.previous = previous
        self.transmogrifier = transmogrifier

        self.key = defaultMatcher(options, 'key', name)
        self.filename = options.get('filename')
        if self.filename:
            self.filename = options['filename'] = self.filename

        self.rowkey = options.get('row-key')
        if 'row-key' in options:
            self.rowkey = Expression(self.rowkey, transmogrifier, name,
                                     options)
            self.rowvalue = Expression(options.get('row-value', 'filename'),
                                       transmogrifier, name, options)

        self.dialect = options.get('dialect', 'excel')
        self.restkey = options.get('restkey', '_csvsource_rest')
        self.fmtparam = dict((key[len('fmtparam-'):],
                              Expression(value, transmogrifier, name, options)(
                                  options, key=key[len('fmtparam-'):]))
                             for key, value in options.iteritems()
                             if key.startswith('fmtparam-'))
        self.fieldnames = options.get('fieldnames')
        if self.fieldnames:
            self.fieldnames = self.fieldnames.split()
    def __init__(self, transmogrifier, name, options, previous):
        self.previous = previous

        self.logger = logging.getLogger(options.get("name", transmogrifier.configuration_id + "." + name))

        self.key = defaultMatcher(options, "url-key", name, "url")
        self.cachekey = Expression(options.get("cache-key", "string:_cache"), transmogrifier, name, options)
        self.headerskey = Expression(options.get("headers-key", "string:_headers"), transmogrifier, name, options)
        self.headersext = options.get("headers-extension", mimetypes.guess_extension("message/rfc822"))

        self.cachedir = resolvePackageReferenceOrFile(
            options.get("cache-directory", os.path.join(os.environ.get("PWD", os.getcwd()), "var/urlopener.cache.d"))
        )
        if not os.path.isdir(self.cachedir):
            os.makedirs(self.cachedir)
        self.defaultpagename = options.get("default-page-name", ".{}.cache".format(options["blueprint"]))

        handlers = Expression(options.get("handlers", "python:[]"), transmogrifier, name, options)(options)
        if "ignore-error" in options:
            self.ignore_error = Expression(options["ignore-error"], transmogrifier, name, options)
            self.ignore_handler = HTTPDefaultErrorHandler()
            self.ignore_handler.section = self
            handlers.append(self.ignore_handler)
        if not [handler for handler in handlers if isinstance(handler, urllib2.HTTPRedirectHandler)]:
            handlers.append(HTTPRedirectHandler())
        self.opener = urllib2.build_opener(*handlers)
Esempio n. 4
0
    def __init__(self, transmogrifier, name, options, previous):
        self.previous = previous
        self.relinker = Relinker(transmogrifier, name, options, self.tidy())
        self.condition = Condition(options.get('condition', 'python:True'),
                                   transmogrifier, name, options)
        self.logger = logging.getLogger(name)
        self.options = options

        self.locale = getattr(options, 'locale', 'en')
        self.invalid_ids = options.get('invalid_ids', '').split()

        self.link_expr = None
        self.name = name
        self.logger = logging.getLogger(name)
        if options.get('link_expr', None):
            self.link_expr = Expression(options['link_expr'], transmogrifier,
                                        name, options)
        self.use_title = Condition(options.get('use_title', 'python:False'),
                                   transmogrifier, name, options)
        #util = queryUtility(IURLNormalizer)
        #if util:
        #    self.normalize = util.normalize
        #else:
        self.locale = Expression(options.get('locale', 'python:None'),
                                 transmogrifier, name, options)
Esempio n. 5
0
 def __init__(self, transmogrifier, name, options, previous):
     self.previous = previous
     self.key = Expression(options['key'], transmogrifier, name, options)
     self.pattern = Expression(options['pattern'], transmogrifier, name,
                               options)
     self.repl = Expression(options['repl'], transmogrifier, name, options)
     self.condition = Condition(options.get('condition', 'python:True'),
                                transmogrifier, name, options)
    def __init__(self, transmogrifier, name, options, previous):
        self.previous = previous
        self.locale = Expression(options.get('locale', 'python:None'),
                                 transmogrifier, name, options)
        self.destinationkey = Expression(
            options.get('destination-key', 'string:_id'), transmogrifier, name,
            options)

        self.sourcekey = Matcher(options.get('source-key', 'title'))
Esempio n. 7
0
 def __init__(self, transmogrifier, name, options, previous):
     self.previous = previous
     self.datakey = defaultMatcher(options, 'data-key', name, 'data')
     self.mimetype = Expression(options['mimetype'], transmogrifier, name,
                                options)
     self.field = Expression(options['field'], transmogrifier, name,
                             options)
     self.condition = Condition(options.get('condition', 'python:True'),
                                transmogrifier, name, options)
 def __init__(self, transmogrifier, name, options, previous):
     self.options = options
     self.previous = previous
     self.textsource = Expression(options.get('textsource', 'text'),
                                  transmogrifier, name, options)
     self.sourcedomain = Expression(options.get('sourcedomain', ''),
                                    transmogrifier, name, options)
     self.targetcontainer_path = Expression(
         options.get('targetcontainer_path', 'images'), transmogrifier,
         name, options)
    def __init__(self, transmogrifier, name, options, previous):
        self.previous = previous
        self.condition = Condition(options.get('condition', 'python:True'),
                                   transmogrifier, name, options)
        self.items = IAnnotations(transmogrifier)[LISTKEY][options['section']]

        self.keys = Expression(options.get('keys', 'nothing'), transmogrifier,
                               name, options)
        self.copykeys = Expression(options.get('copy-keys', 'nothing'),
                                   transmogrifier, name, options)
Esempio n. 10
0
 def __init__(self, transmogrifier, name, options, previous):
     self.previous = previous
     self.condition = Condition(options.get('condition', 'python:True'),
                                transmogrifier, name, options)
     self.strip_prefixes = Expression(
         options.get('strip-prefixes', 'python: []'), transmogrifier, name,
         options)
     self.mapping = Expression(options['mapping'], transmogrifier, name,
                               options)
     self.pathkey = defaultMatcher(options, 'path-key', name, 'path')
    def __init__(self, transmogrifier, name, options, previous):
        self.previous = previous
        self.relinker = Relinker(transmogrifier, '%s' % name, options,
                                 self.ouriter())
        self.field_expr = Expression(options.get('field_expr', 'python:None'),
                                     transmogrifier, name, options)
        self.field = options.get('field', '').strip()
        self.breadcrumb_field = options.get('breadcrumb_field', '').strip()
        self.condition = Condition(options.get('condition', 'python:True'),
                                   transmogrifier, name, options)
        self.logger = logging.getLogger(name)
        self.options = options
        # if set will ensure all sitemap items are of this type, using defaultpage if needed
        self.folder_type = options.get('folder-type', 'Folder').strip()
        self.convert_to_folders = False
        self.exclusion = options.get('exclude-from-navigation-key',
                                     'exclude-from-navigation')
        self.title_key = options.get('title-key', 'title')
        self.post_sub = [
            s.strip() for s in options.get(
                'path_sub', options.get('post-sub', '')).split('\n')
            if s.strip()
        ]

        self.name = name
        self.logger = logging.getLogger(name)
Esempio n. 12
0
    def __init__(self, transmogrifier, name, options, previous):
        self.previous = previous
        self.context = transmogrifier.context if transmogrifier.context else getSite(
        )  # noqa
        self.name = name
        self.pathkey = defaultMatcher(options, 'path-key', name, 'path')
        self.fileskey = options.get('files-key', '_files').strip()
        self.disable_constraints = Expression(
            options.get('disable-constraints', 'python: False'),
            transmogrifier,
            name,
            options,
        )

        # if importing from collective.jsonify exported json structures, there
        # is an datafield entry for binary data, which' prefix can be
        # configured.
        self.datafield_prefix = options.get('datafield-prefix', '_datafield_')

        # create logger
        if options.get('logger'):
            self.logger = logging.getLogger(options['logger'])
            self.loglevel = getattr(logging, options['loglevel'], None)
            if self.loglevel is None:
                # Assume it's an integer:
                self.loglevel = int(options['loglevel'])
            self.logger.setLevel(self.loglevel)
            self.log = lambda s: self.logger.log(self.loglevel, s)
        else:
            self.log = None
Esempio n. 13
0
    def __init__(self, transmogrifier, name, options, previous):
        self.previous = previous
        self.context = transmogrifier.context
        self.name = name
        self.pathkey = defaultMatcher(options, 'path-key', name, 'path')
        self.fileskey = options.get('files-key', '_files').strip()
        self.disable_constraints = Expression(
            options.get('disable-constraints', 'python: False'),
            transmogrifier,
            name,
            options,
        )

        # create logger
        if options.get('logger'):
            self.logger = logging.getLogger(options['logger'])
            self.loglevel = getattr(logging, options['loglevel'], None)
            if self.loglevel is None:
                # Assume it's an integer:
                self.loglevel = int(options['loglevel'])
            self.logger.setLevel(self.loglevel)
            self.log = lambda s: self.logger.log(self.loglevel, s)
        else:
            self.log = None

        self.errored = IAnnotations(transmogrifier).setdefault(ERROREDKEY, [])
 def __init__(self, transmogrifier, name, options, previous):
     self.previous = previous
     self.fields = Expression(options.get('fields', 'python:False'),
                              transmogrifier, name, options)
     self.condition = Condition(options.get('condition', 'python:True'),
                                transmogrifier, name, options)
     self.defaultpage = options.get('defaultpage', 'index-html')
     self.logger = logging.getLogger(name)
 def __init__(self, transmogrifier, name, options, previous):
     keys = options.get('keys') or ''
     self.keys = Matcher(*keys.splitlines())
     if keys:
         self.dest = Expression(options['destination'], transmogrifier,
                                name, options)
     self.delete = Matcher(*options.get('delete', '').splitlines())
     self.condition = Condition(options.get('condition', 'python:True'),
                                transmogrifier, name, options)
     self.previous = previous
Esempio n. 16
0
    def __init__(self, transmogrifier, name, options, previous):
        """The FieldMapper Blueprint provides powerful functionality to map and
        modify values on the given item.
        """
        self.mapper = Expression(options['field-mapping'], transmogrifier,
                                 name, options)

        self.condition = Condition(options.get('condition', 'python:True'),
                                   transmogrifier, name, options)

        self.previous = previous
Esempio n. 17
0
    def __init__(self, transmogrifier, name, options, previous):
        self.previous = previous
        self.condition = Condition(options.get('condition', 'python:True'),
                                   transmogrifier, name, options)

        self.path_key = options.get('path-key', '_path')
        self.contenttype_key = options.get('contenttype-key', '_type')
        self.id_key = options.get('id-key', '_id')
        self.interfaces_key = options.get('interfaces-key', '_interfaces')
        self.annotations_key = options.get('annotations-key', '_annotations')

        self.content_type = options.get('content-type')
        self.additional_id = Expression(options.get('additional-id'),
                                        transmogrifier, name, options)
        self.interfaces = Expression(options.get('_interfaces', 'python:[]'),
                                     transmogrifier, name, options)
        self.annotations = Expression(options.get('_annotations', 'python:{}'),
                                      transmogrifier, name, options)
        self.metadata = Expression(options.get('metadata-key', 'python:{}'),
                                   transmogrifier, name, options)
        self.path = None
Esempio n. 18
0
 def __init__(self, transmogrifier, name, options, previous):
     self.previous = previous
     self.transmogrifier = transmogrifier
     self.storage = IAnnotations(transmogrifier).get(ANNOTATION_KEY)
     self.csv_headers = Condition(options.get('csv_headers', 'python:True'), transmogrifier, name, options)
     self.dialect = safe_unicode(options.get('dialect', 'excel'))
     self.roe = bool(int(options.get('raise_on_error', '1')))
     self.fmtparam = dict(
         (key[len('fmtparam-'):],
          Expression(value, transmogrifier, name, options)(
              options, key=key[len('fmtparam-'):])) for key, value
         in options.iteritems() if key.startswith('fmtparam-'))
 def __init__(self, transmogrifier, name, options, previous):
     self.previous = previous
     self.min_links = options.get('min_links', 2)
     self.max_uplinks = options.get('max_uplinks', 2)
     self.mode = options.get('mode', 'links')
     if self.mode == 'path':
         self.parent_path = Expression(options['parent_path'],
                                       transmogrifier, name, options)
     self.treeserializer = TreeSerializer(transmogrifier, name, options,
                                          previous)
     self.condition = Condition(options.get('condition', 'python:True'),
                                transmogrifier, name, options)
     self.logger = logging.getLogger(name)
    def __init__(self, transmogrifier, name, options, previous):
        self.previous = previous

        self.logger = logging.getLogger(name)

        self.trees = Expression(
            options.get('trees', "python:item.get('_trees', ())"),
            transmogrifier, name, options)

        self.cache = options.get('cache', 'false').lower() == 'true'
        self.seen = set()

        # By default, insert matching elements
        self.xpath = options.get('xpath', self.xpath)
        self.elementkey = Expression(options.get('key', 'nothing'),
                                     transmogrifier, name, options)

        # By default, insert references to parent items
        self.parentkey = Expression(
            options.get('parent-key', 'string:_parent'), transmogrifier, name,
            options)

        # By default, only insert a type for folders
        self.typekey = Expression(options.get('type-key', "string:_type"),
                                  transmogrifier, name, options)
        self.typevalue = Expression(options.get('type-value', "string:Folder"),
                                    transmogrifier, name, options)

        # By default yield default pages for folders
        #   but do not keep references to child items
        self.defaultpagekey = Expression(
            options.get('default-page-key', 'nothing'), transmogrifier, name,
            options)
        self.isdefaultpagekey = Expression(
            options.get('is-default-page-key', 'string:_is_defaultpage'),
            transmogrifier, name, options)
        self.childrenkey = Expression(options.get('children-key', 'nothing'),
                                      transmogrifier, name, options)

        self.keys = [(key,
                      Expression(options[self.prefix + key], transmogrifier,
                                 name, options))
                     for key in options.get('element-keys', '').splitlines()
                     if key]
Esempio n. 21
0
 def __init__(self, transmogrifier, name, options, previous):
     self.previous = previous
     self.pathkey = options.get('path-key', '_path')
     self.typekey = options.get('type-key', '_type')
     self.foldertype = options.get('folder-type', 'Folder')
     self.dirname = options['dirname'] = resolvePackageReferenceOrFile(
         options['dirname'])
     self.sortkey = Expression(
         options.get(
             'sort-key', "python:not basename.lower() == '.htaccess', "
             "not basename.lower().startswith('index'), "
             "not 'overview' in basename.lower(), basename"),
         transmogrifier, name, options)
    def __init__(self, transmogrifier, name, options, previous):
        self.previous = previous

        self.logger = logging.getLogger(options.get(
            'name', transmogrifier.configuration_id + '.' + name))

        self.key = defaultMatcher(options, 'url-key', name, 'url')
        self.cachekey = Expression(
            options.get('cache-key', 'string:_cache'),
            transmogrifier, name, options)
        self.headerskey = Expression(
            options.get('headers-key', 'string:_headers'),
            transmogrifier, name, options)
        self.headersext = options.get(
            'headers-extension', mimetypes.guess_extension('message/rfc822'))

        self.cachedir = resolvePackageReferenceOrFile(
            options.get('cache-directory',
                        os.path.join(os.environ.get('PWD', os.getcwd()),
                                     'var/urlopener.cache.d')))
        if not os.path.isdir(self.cachedir):
            os.makedirs(self.cachedir)
        self.defaultpagename = options.get(
            'default-page-name', '.{0}.cache'.format(options['blueprint']))

        handlers = Expression(
            options.get('handlers', 'python:[]'),
            transmogrifier, name, options)(options)
        if 'ignore-error' in options:
            self.ignore_error = Expression(
                options['ignore-error'], transmogrifier, name, options)
            self.ignore_handler = HTTPDefaultErrorHandler()
            self.ignore_handler.section = self
            handlers.append(self.ignore_handler)
        if not [handler for handler in handlers
                if isinstance(handler, urllib2.HTTPRedirectHandler)]:
            handlers.append(HTTPRedirectHandler())
        self.opener = urllib2.build_opener(*handlers)
Esempio n. 23
0
    def __init__(self, transmogrifier, name, options, previous):
        self.previous = previous
        self.context = transmogrifier.context
        self.wftool = getToolByName(self.context, 'portal_workflow')

        self.pathkey = options.get('path-key', '_path')
        self.history_key = options.get('history-key', '_workflow_history')
        self.state_key = options.get('state-key', '_review_state')

        self.update_history = options.get('update-history', True)

        self.old_workflow_id = options.get('old-workflow-id')
        self.new_workflow_id = options.get('new-workflow-id',
                                           self.old_workflow_id)

        self.state_map = Expression(options.get('state-map', 'python:{}'),
                                    transmogrifier, name, options)
        self.transition_map = Expression(
            options.get('transition-map', 'python:{}'), transmogrifier, name,
            options)

        self.condition = Condition(options.get('condition', 'python:True'),
                                   transmogrifier, name, options)
Esempio n. 24
0
    def __init__(self, transmogrifier, name, options, previous):
        # self.key = Expression(options['key'], transmogrifier, name, options)
        self.template = Expression(options['template'], transmogrifier, name,
                                   options)
        # self.value = Expression(options['value'], transmogrifier, name,
        #                         options)
        self.condition = Condition(options.get('condition', 'python:True'),
                                   transmogrifier, name, options)
        self.previous = previous

        self.available_operators = ['*', '', '=']

        self.anno = IAnnotations(transmogrifier)
        self.storage = self.anno.setdefault(VALIDATIONKEY, [])
    def __init__(self, transmogrifier, name, options, previous):
        self.previous = previous

        self.logger = logging.getLogger(
            options.get('name', transmogrifier.configuration_id + '.' + name))

        self.key = defaultMatcher(options, 'url-key', name, 'url')
        self.cachekey = Expression(options.get('cache-key', 'string:_cache'),
                                   transmogrifier, name, options)
        self.headerskey = Expression(
            options.get('headers-key', 'string:_headers'), transmogrifier,
            name, options)
        self.headersext = options.get(
            'headers-extension', mimetypes.guess_extension('message/rfc822'))

        self.cachedir = resolvePackageReferenceOrFile(
            options.get(
                'cache-directory',
                os.path.join(os.environ.get('PWD', os.getcwd()),
                             'var/urlopener.cache.d')))
        if not os.path.isdir(self.cachedir):
            os.makedirs(self.cachedir)
        self.defaultpagename = options.get(
            'default-page-name', '.{0}.cache'.format(options['blueprint']))

        handlers = Expression(options.get('handlers', 'python:[]'),
                              transmogrifier, name, options)(options)
        if 'ignore-error' in options:
            self.ignore_error = Expression(options['ignore-error'],
                                           transmogrifier, name, options)
            self.ignore_handler = HTTPDefaultErrorHandler()
            self.ignore_handler.section = self
            handlers.append(self.ignore_handler)
        if not [
                handler for handler in handlers
                if isinstance(handler, urllib2.HTTPRedirectHandler)
        ]:
            handlers.append(HTTPRedirectHandler())
        self.opener = urllib2.build_opener(*handlers)
 def __init__(self, transmogrifier, name, options, previous):
     self.previous = previous
     self.name = name
     self.logger = logging.getLogger(name)
     self.ignore_duplicates = options.get(
         'ignore_duplicates', 'False').lower() in ['true', 'on']
     self.broken_link_normalise = []
     for f in options.get('broken_link_normalise', '').split('\n'):
         f = f.strip()
         if not f:
             continue
         expr = Expression(f,
                           transmogrifier,
                           name,
                           options,
                           re=re,
                           urlparse=urlparse)
         self.broken_link_normalise.append(expr)
Esempio n. 27
0
    def __init__(self, transmogrifier, name, options, previous):
        self.previous = previous
        self.context = transmogrifier.context
        self.logger = logging.getLogger(options['blueprint'])

        self.pathkey = options.get('path-key', '_path')

        self.portlet_properties = Expression(
            options.get('portlet-properties', 'python:{}'),
            transmogrifier, name, options)

        self.condition = Condition(options.get('condition', 'python:True'),
            transmogrifier, name, options)

        self.portlet_handler = PortletHandler(
            options.get('manager-name'),
            options.get('assignment-path'),
            options.get('portlet-id')
        )
Esempio n. 28
0
 def __init__(self, transmogrifier, name, options, previous):
     self.previous = previous
     self.mapping = Expression(options['mapping'], transmogrifier, name,
                               options)
     self.typekey = defaultMatcher(options, 'type-key', name, 'type')
Esempio n. 29
0
 def __init__(self, transmogrifier, name, options, previous):
     self.previous = previous
     self.logger = logging.getLogger(options['blueprint'])
     self.print_out = Expression(options.get('print_out'), transmogrifier,
                                 name, options)
Esempio n. 30
0
 def __init__(self, transmogrifier, name, options, previous):
     self.previous = previous
     self.logger = logging.getLogger(options['blueprint'])
     self.fields = Expression(options['fields'], transmogrifier, name,
                              options)
Esempio n. 31
0
    def __init__(self, transmogrifier, name, options, previous):
        super(AdditionalObjectInserter, self).__init__(transmogrifier, name,
                                                       options, previous)

        self.path = Expression(options.get('new-path', None), transmogrifier,
                               name, options)