How to use the ural.facebook.FacebookParsedItem function in ural

To help you get started, we’ve selected a few ural examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github medialab / ural / ural / facebook.py View on Github external
return urljoin(BASE_FACEBOOK_URL, '/%s' % self.handle)

    def __repr__(self):
        class_name = self.__class__.__name__

        return (
            '<%(class_name)s id=%(id)s handle=%(handle)s>'
        ) % {
            'class_name': class_name,
            'id': self.id,
            'handle': self.handle
        }


class FacebookHandle(FacebookParsedItem):
    __slots__ = ('handle',)

    def __init__(self, handle):
        self.handle = handle

    @property
    def url(self):
        return urljoin(BASE_FACEBOOK_URL, '/%s' % self.handle)

    def __repr__(self):
        class_name = self.__class__.__name__

        return (
            '<%(class_name)s handle=%(handle)s>'
        ) % {
            'class_name': class_name,
github medialab / ural / ural / facebook.py View on Github external
return result


class FacebookParsedItem(object):
    def __eq__(self, other):
        if self.__class__ != other.__class__:
            return False

        for attr in self.__slots__:
            if getattr(self, attr) != getattr(other, attr):
                return False

        return True


class FacebookUser(FacebookParsedItem):
    __slots__ = ('id', 'handle')

    def __init__(self, user_id, handle=None):
        self.id = user_id
        self.handle = handle

    @property
    def url(self):
        if self.handle is None:
            return urljoin(BASE_FACEBOOK_URL, '/profile.php?id=%s' % self.id)

        return urljoin(BASE_FACEBOOK_URL, '/%s' % self.handle)

    def __repr__(self):
        class_name = self.__class__.__name__
github medialab / ural / ural / facebook.py View on Github external
    @property
    def url(self):
        return urljoin(BASE_FACEBOOK_URL, '/%s' % self.handle)

    def __repr__(self):
        class_name = self.__class__.__name__

        return (
            '<%(class_name)s handle=%(handle)s>'
        ) % {
            'class_name': class_name,
            'handle': self.handle
        }


class FacebookPost(FacebookParsedItem):
    __slots__ = ('id', 'parent_id', 'group_id', 'parent_handle')

    def __init__(self, post_id, parent_id=None, group_id=None, parent_handle=None):
        self.id = post_id
        self.parent_id = parent_id
        self.group_id = group_id
        self.parent_handle = parent_handle

    @property
    def url(self):
        if self.parent_handle is not None:
            return urljoin(BASE_FACEBOOK_URL, '/%s/posts/%s' % (self.parent_handle, self.id))

        if self.parent_id is not None:
            return urljoin(BASE_FACEBOOK_URL, '/permalink.php?story_fbid=%s&id=%s' % (self.id, self.parent_id))