Code Duplication    Length = 33-35 lines in 2 locations

th_wallabag/my_wallabag.py 1 location

@@ 125-159 (lines=35) @@
122
        trigger_id = kwargs['trigger_id']
123
        cache.set('th_wallabag_' + str(trigger_id), data)
124
125
    def save_data(self, trigger_id, **data):
126
        """
127
            let's save the data
128
129
            :param trigger_id: trigger ID from which to save data
130
            :param data: the data to check to be used and save
131
            :type trigger_id: int
132
            :type data:  dict
133
            :return: the status of the save statement
134
            :rtype: boolean
135
        """
136
        if 'link' in data and data['link'] is not None:
137
            if len(data['link']) > 0:
138
                # get the wallabag data for this trigger
139
                from th_wallabag.models import Wallabag
140
                trigger = Wallabag.objects.get(trigger_id=trigger_id)
141
142
                title = self.set_title(data)
143
                # convert htmlentities
144
                title = HtmlEntities(title).html_entity_decode
145
146
                status = self._create_entry(userservice_id=data['userservice_id'],
147
                                            url=data['link'],
148
                                            title=title,
149
                                            tags=trigger.tag.lower())
150
            else:
151
                logger.warning(
152
                    "no link provided for trigger ID {}, so we ignore it".format(trigger_id))
153
                status = True
154
        else:
155
            logger.critical(
156
                "no token provided for trigger ID {}".format(trigger_id))
157
            status = False
158
159
        return status
160
161
    def auth(self, request):
162
        """

th_pocket/my_pocket.py 1 location

@@ 112-144 (lines=33) @@
109
110
        return data
111
112
    def save_data(self, trigger_id, **data):
113
        """
114
            let's save the data
115
116
            :param trigger_id: trigger ID from which to save data
117
            :param data: the data to check to be used and save
118
            :type trigger_id: int
119
            :type data:  dict
120
            :return: the status of the save statement
121
            :rtype: boolean
122
        """
123
        if 'link' in data and data['link'] is not None:
124
            if len(data['link']) > 0:
125
                # get the pocket data of this trigger
126
                from th_pocket.models import Pocket as PocketModel
127
                trigger = PocketModel.objects.get(trigger_id=trigger_id)
128
129
                title = self.set_title(data)
130
                # convert htmlentities
131
                title = HtmlEntities(title).html_entity_decode
132
133
                status = self._create_entry(url=data['link'],
134
                                            title=title,
135
                                            tags=(trigger.tag.lower()))
136
            else:
137
                logger.warning(
138
                    "no link provided for trigger ID {}, so we ignore it".format(trigger_id))
139
                status = True
140
        else: 
141
            logger.critical(
142
                "no token provided for trigger ID {}".format(trigger_id))
143
            status = False
144
        return status
145
146
    def auth(self, request):
147
        """