Example #1
0
 def __init__(self,
              activity_id,
              activity_class="actor",
              activity_type="person"):
     """
     Initializes the linked activity
     :param activity_id: String. The ID that is being followed or watched.
     :param activity_class: String. Single word. The type of activities that are being followed and watched.
                            This must be either "actor" or "object"
     :param activity_type: String. Single word. The type of feed component that is being followed or watched.
                           For example, if the class is "actor" then it's type could be "Person", "User" or "Member".
                           If the class is "object" then its type could be "Document", or "Project".
     """
     temp = activity_id.split(" ")
     if len(temp) == 1:
         self._activity_id = activity_id
     else:
         raise IDError()
     if not activity_class.isalpha():
         raise KeyWordError(activity_class)
     if activity_class == "actor" or activity_class == "object":
         self._activity_class = activity_class.lower()
     else:
         raise ActivityClassError
     if not activity_type.isalpha():
         raise KeyWordError(activity_type)
     self._activity_type = activity_type.lower()
Example #2
0
 def __init__(
     self,
     actor_id,
     linked_activity,
     linked=datetime.datetime.now(),
     link_type="follow",
     link_weight=1,
     extra=None,
 ):
     """
     Initialize the Link
     :param actor_id: Actor ID who's link is being declared
     :param linked_activity: Linked activity. The type of activity feeds that such connection would bring
     :param linked: Linked date and time
     :param link_type: Link type: Usually follow or watch.
     :param link_weight: The weight of the connection between the actor ID and who or what is being
                         followed / watched
     :param extra: Dict of extra data
     """
     temp = actor_id.split(" ")
     if len(temp) == 1:
         self._actor_id = actor_id
     else:
         raise IDError()
     if not isinstance(linked, datetime.datetime):
         raise LinkedTypeError
     self._linked = linked
     if not link_type.isalpha():
         raise KeyWordError(link_type)
     self._link_type = link_type
     if not isinstance(linked_activity, LinkedActivity):
         raise LinkedActivityObjectError
     self._linked_activity = linked_activity
     if extra is not None:
         if not isinstance(extra, dict):
             raise ExtraTypeError()
     self._extra = extra
     if isinstance(link_weight, int) or isinstance(link_weight, float):
         self._link_weight = link_weight
     else:
         raise WeightTypeError()
Example #3
0
 def __init__(self, origin_id, origin_type, extra=None):
     """
     Initializes the Origin
     :param origin_id: String. The unique ID the origin. Only one ID is accepted.
     :param origin_type: String. Single word. Provides some degree of specificity to the origin. E.g., Collection
     :param extra: Use this dict to store extra information at origin level.
                   IMPORTANT NOTE: This dict is "non-analyzable" which means that ES does not perform any
                   operations on it thus it cannot be used to order, aggregate, or filter query results.
     """
     temp = origin_id.split(" ")
     if len(temp) == 1:
         self._origin_id = origin_id
     else:
         raise IDError()
     if not origin_type.isalpha():
         raise KeyWordError(origin_type)
     self._origin_type = origin_type.lower()
     if extra is not None:
         if not isinstance(extra, dict):
             raise ExtraTypeError()
     self._extra = extra
Example #4
0
 def __init__(self, actor_id, actor_type, extra=None):
     """
     Initializes the Actor
     :param actor_id: String. The unique id of the actor. Only one ID is accepted.
     :param actor_type: String. Single word. The type of actor performing the activity. E.g., Person, User, Member.
                        See https://www.w3.org/TR/activitystreams-vocabulary/#actor-types for more info.
     :param extra: Use this dict to store extra information at actor level.
                   IMPORTANT NOTE: This dict is "non-analyzable" which means that ES does not perform any
                   operations on it thus it cannot be used to order, aggregate, or filter query results.
     """
     temp = actor_id.split(" ")
     if len(temp) == 1:
         self._actor_id = actor_id
     else:
         raise IDError()
     if not actor_type.isalpha():
         raise KeyWordError(actor_type)
     self._actor_type = actor_type.lower()
     if extra is not None:
         if not isinstance(extra, dict):
             raise ExtraTypeError()
     self._extra = extra
Example #5
0
 def __init__(self, object_id, object_type, extra=None):
     """
     Initializes the Object
     :param object_id: String. Single ID. The unique id of the object.
     :param object_type: String. Single word. Provides some degree of specificity to the object. E.g., Document,
                         Project, Form.
                         See https://www.w3.org/TR/activitystreams-vocabulary/#object-types for more info
     :param extra: Use this dict to store extra information at object level.
                   IMPORTANT NOTE: This dict is "non-analyzable" which means that ES does not perform any
                   operations on it thus it cannot be used to order, aggregate, or filter query results.
     """
     temp = object_id.split(" ")
     if len(temp) == 1:
         self._object_id = object_id
     else:
         raise IDError()
     if not object_type.isalpha():
         raise KeyWordError(object_type)
     self._object_type = object_type.lower()
     if extra is not None:
         if not isinstance(extra, dict):
             raise ExtraTypeError()
     self._extra = extra
Example #6
0
    def __init__(self, actor_id):
        """
        Initialize the base aggregator
        :param actor_id: The actor ID that will be used to query for activity feeds
        """
        temp = actor_id.split(" ")
        if len(temp) == 1:
            self._actor_id = actor_id
        else:
            raise IDError()

        self._connection = None
        self._feed_index = None
        self._network_array = []
        self.query_dict = (
            None  #: The query dict that ES will execute to fetch activity feeds
        )
        self.es_feed_result = (
            None  #: The fetched activity feeds by ES. Used by subclasses in get_feeds()
        )
        self._order = "desc"  #: Order is descending at start
        self._result_size = 10000  #: Result size is 10000 records at start
        self._result_from = 0  #: From is 0 at start
        self._top_hits_size = 100  #: Top hits size is 100 at start
Example #7
0
 def object_id(self, value):
     temp = value.split(" ")
     if len(temp) == 1:
         self._object_id = value
     else:
         raise IDError()
Example #8
0
 def activity_id(self, value):
     temp = value.split(" ")
     if len(temp) == 1:
         self._activity_id = value
     else:
         raise IDError()