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()
def activity_class(self, value): if not value.isalpha(): raise KeyWordError(value) if value == "actor" or value == "object": self._activity_class = value.lower() else: raise ActivityClassError
def __init__( self, activity_type, activity_actor, activity_object, published=datetime.datetime.now(), activity_origin=None, activity_target=None, extra=None, ): """ Initialize the Activity :param activity_type: Single word in infinitive. Also know as "verb", it describes some form of action that may happen, is currently happening, or has already happened. See https://www.w3.org/TR/activitystreams-vocabulary/#dfn-activity for more info. :param activity_actor: Object. Describes the entity that is performing the activity. See https://www.w3.org/TR/activitystreams-vocabulary/#dfn-actor for more info. :param activity_object: Object. Describes an object of any kind linked to the action itself. See https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object for more info. :param published: Date when the activity was published :param activity_origin: Optional object. The origin is applicable to any type of activity for which the English preposition "from" can be considered applicable in the sense of identifying the origin, source or provenance of the activity's object. See https://www.w3.org/TR/activitystreams-vocabulary/#origin-target for more info. :param activity_target: Optional object. The target property is applicable to any type of activity for which the English preposition "to" can be considered applicable in the sense of identifying the indirect object or destination of the activity's object. See https://www.w3.org/TR/activitystreams-vocabulary/#origin-target for more info. :param extra: Use this dict to store extra information at activity 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. """ if not isinstance(activity_actor, Actor): raise ActorObjectError() self._activity_actor = activity_actor if not isinstance(activity_object, Object): raise ObjectObjectError() self._activity_object = activity_object if activity_origin is not None: if not isinstance(activity_origin, Origin): raise OriginObjectError() self._activity_origin = activity_origin if activity_target is not None: if not isinstance(activity_target, Target): raise TargetObjectError() self._activity_target = activity_target if extra is not None: if not isinstance(extra, dict): raise ExtraTypeError() self._extra = extra if not isinstance(published, datetime.datetime): raise PublishedTypeError() self._published = published if not activity_type.isalpha(): raise KeyWordError(activity_type) self._activity_type = activity_type.lower()
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()
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
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
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
def object_type(self, value): if not value.isalpha(): raise KeyWordError(value) self._object_type = value.lower()
def activity_type(self, value): if not value.isalpha(): raise KeyWordError(value) self._activity_type = value.lower()
def link_type(self, value): if not value.isalpha(): raise KeyWordError(value) self._link_type = value