Code Duplication    Length = 29-29 lines in 2 locations

th_pocket/my_pocket.py 1 location

@@ 119-147 (lines=29) @@
116
            title = HtmlEntities(title).html_entity_decode
117
118
            try:
119
                self.pocket.add(
120
                    url=data['link'], title=title, tags=(trigger.tag.lower()))
121
122
                sentence = str('pocket {} created').format(data['link'])
123
                logger.debug(sentence)
124
                status = True
125
            except Exception as e:
126
                logger.critical(e)
127
                status = False
128
129
        elif self.token and 'link' in data and data['link'] is not None\
130
                and len(data['link']) == 0:
131
            logger.warning(
132
                "no link provided for trigger ID {}, so we ignore it".format(trigger_id))
133
            status = True
134
        else: 
135
            logger.critical(
136
                "no token provided for trigger ID {}".format(trigger_id))
137
            status = False
138
        return status
139
140
    def auth(self, request):
141
        """
142
            let's auth the user to the Service
143
            :param request: request object
144
            :return: callback url
145
            :rtype: string that contains the url to redirect after auth
146
        """
147
        callback_url = self.callback_url(request, 'pocket')
148
149
        request_token = Pocket.get_request_token(
150
            consumer_key=self.consumer_key,

th_readability/my_readability.py 1 location

@@ 118-146 (lines=29) @@
115
            if trigger.tag is not None and len(trigger.tag) > 0:
116
                try:
117
                    self.client.add_tags_to_bookmark(
118
                        bookmark_id, tags=(trigger.tag.lower()))
119
                    sentence = str('readability {} created item id {}').format(
120
                        data['link'], bookmark_id)
121
                    logger.debug(sentence)
122
                    status = True
123
                except Exception as e:
124
                    logger.critical(e)
125
                    status = False
126
127
        elif self.token and 'link' in data and data['link'] is not None\
128
                and len(data['link']) == 0:
129
            logger.warning(
130
                "no link provided for trigger ID {}, so we ignore it".format(trigger_id))
131
            status = True
132
        else: 
133
            logger.critical(
134
                "no token provided for trigger ID {}".format(trigger_id))
135
            status = False
136
        return status
137
138
    def auth(self, request):
139
        """
140
            let's auth the user to the Service
141
            :param request: request object
142
            :return: callback url
143
            :rtype: string that contains the url to redirect after auth
144
        """
145
        request_token = super(ServiceReadability, self).auth(request)
146
        callback_url = self.callback_url(request, 'readability')
147
148
        # URL to redirect user to, to authorize your app
149
        auth_url_str = '%s?oauth_token=%s&oauth_callback=%s'