Esempio n. 1
0
  def __init__(self, parent, description):
    super(Mapper, self).__init__(parent, description)
    self.target = description.get('target', Name.NAME)
    self.source = description.get('source')
    self.mapping = description.get('mapping', {})
    handlers = description.get('handlers', [])
    self.handlers = Load.make(self, handlers)

    for key, element in self.mapping.iteritems():
      self.mapping[key] = Load.make_one(self, element)
Esempio n. 2
0
    def __init__(self, parent, description):
        super(Mapper, self).__init__(parent, description)
        self.target = description.get('target', Name.NAME)
        self.source = description.get('source')
        self.mapping = description.get('mapping', {})
        handlers = description.get('handlers', [])
        self.handlers = Load.load_elements(self, handlers)

        for key, element in six.iteritems(self.mapping):
            self.mapping[key] = Load.load_one_element(self, element)
Esempio n. 3
0
  def __init__(self, parent, description, full_slave=True, name=None):
    self.parent = parent
    self.description = description
    self.load_time = time.time()
    self.name = name or description['type']
    self.pause_time = 0

    super(Element, self).__init__()

    elements = description.get('elements', None)
    if elements:
      # This has to be local to avoid an infinite loop...
      # pylint: disable=R0401
      from echomesh.element import Load
      # pylint: enable=R0401

      self.elements = Load.load_elements(self, elements)
      if full_slave:
        self.add_slave(*self.elements)
      else:
        self.add_pause_only_slave(*self.elements)
    else:
      self.elements = []

    self.element_table = dict((e.name, e) for e in reversed(self.elements))
    self.variables = {}

    for key in description.keys():
      if len(key) > 2 and ((key == 'vars') or 'variables'.startswith(key)):
        items = list(six.iteritems(description[key]))
        self.variables = dict((k, Variable.variable(v, self)) for k, v in items)
        break
Esempio n. 4
0
    def add_elements(self):
        elements = self.description.get('elements', None)
        if elements:
            self.elements = Load.load_elements(self, elements)
            if self.full_slave:
                self.add_slave(*self.elements)
            else:
                self.add_pause_only_slave(*self.elements)
        else:
            self.elements = []

        self.element_table = dict((e.name, e) for e in reversed(self.elements))
Esempio n. 5
0
    def add_elements(self):
        elements = self.description.get('elements', None)
        if elements:
            self.elements = Load.load_elements(self, elements)
            if self.full_slave:
                self.add_slave(*self.elements)
            else:
                self.add_pause_only_slave(*self.elements)
        else:
            self.elements = []

        self.element_table = dict((e.name, e) for e in reversed(self.elements))
Esempio n. 6
0
    def __init__(self, parent, description):
        super(Twitter, self).__init__(
          parent, description, name='Twitter', pause_on_exception=False)
        preload = description.get('preload', DEFAULT_PRELOAD)
        search = description['search']
        if not isinstance(search, list):
            search = [search]

        self.searches = [
            Search(s, self.callback, preload=preload) for s in search]
        self.handler = description.get('handler')
        if self.handler:
            self.handler = Load.load_one_element(self, self.handler)
        self.remove_hashtags = description.get('remove_hashtags', True)
Esempio n. 7
0
  def __init__(self, parent, description):
    super(Twitter, self).__init__(parent, description)
    preload = description.get('preload', DEFAULT_PRELOAD)
    search = description['search']
    if not isinstance(search, list):
      search = [search]

    def callback(twitter):
      if self.handler:
        self.handler.handle(twitter)

    self.searches = [Search(s, callback, preload=preload) for s in search]
    self.handler = description.get('handler')
    if self.handler:
      self.handler = Load.make_one(self, self.handler)
    self.broadcast = description.get('broadcast', not self.handler)