Esempio n. 1
0
    def copy_annotation(self, annotation, item, field):
        copied_ann = annotation.copy('{}|{}'.format(short_guid(),
                                                    short_guid()),
                                     storage=self.storage)
        copied_ann.field = self.copied_fields[field.id]
        item.annotations.add(copied_ann)

        copied_ann.save()
        return copied_ann
Esempio n. 2
0
 def _on_load_started(self):
     self.load_id = short_guid()
     self.sendMessage({
         '_command': 'loadStarted',
         'id': self.load_id,
         'url': self.tab.url
     })
     self.tab.initial_layout_completed = False
Esempio n. 3
0
    def _copy_extractor(self, extractor):
        extractor_id = extractor.id
        if extractor_id in self.copied_extractors:
            return self.copied_extractors[extractor_id]

        copied_extractor = extractor.copy(short_guid(), storage=self.storage)
        copied_extractor.project = self.project

        copied_extractor.save()
        self.copied_extractors[extractor_id] = copied_extractor
        return copied_extractor
Esempio n. 4
0
    def copy_sample(self, sample, spider):
        copied_sample = sample.copy(short_guid(), storage=self.storage)

        copied_sample.spider = spider
        copied_sample.original_body = self._copy_body(sample.original_body,
                                                      sample)
        copied_sample.rendered_body = self._copy_body(sample.rendered_body,
                                                      sample)

        copied_sample.save()
        return copied_sample
Esempio n. 5
0
    def copy_sample(self, sample, spider):
        copied_sample = sample.copy(short_guid(), storage=self.storage)

        copied_sample.spider = spider
        copied_sample.original_body = self._copy_body(sample.original_body,
                                                      sample)
        try:
            copied_sample.rendered_body = self._copy_body(
                sample.rendered_body, sample)
        except AttributeError:
            # Ignore missing rendered body.
            # It will be added when the sample is modified
            pass

        copied_sample.save()
        return copied_sample
Esempio n. 6
0
 def _on_load_started(self):
     self.load_id = short_guid()
     self.sendMessage({'_command': 'loadStarted', 'id': self.load_id,
                       'url': self.tab.url})
     self.tab.initial_layout_completed = False
     return True