@extends(pm.nodetypes.SequenceManager)
    def from_seq(self, seq):
        """Generates maya shots and sequencers with the given
        :class:`anima.previs.Sequence` instance.

        This method is designed to mainly be used with :method:`.from_xml`
        and :method:`.from_edl` methods. It generates new shots or updates them
        by looking at the given :class:`anima.previs.Sequence` instance.

        :param seq: An :class:`anima.previs.Sequence` instance
        :return:
        """
        # now create or update structure
        # create first
        # generate the shot name template first
        shot_name_template = self.get_shot_name_template()
        # get current sequencer
        seqs = self.sequences.get()
        if seqs:
            # we probably need to update shots
            seq1 = seqs[0]

            # update shots
            shots = seq1.shots.get()

            # collect clips
            all_clips = [clip
                         for track in seq.media.video.tracks
                         for clip in track.clips]

            deleted_shots = []
            used_shots = []

            # for each shot sets the anchor point in a temp variable
            for shot in shots:
                shot.anchor = shot.startFrame.get()

            # find the corresponding shots in seq
            for clip in all_clips:
                #is_deleted = True
                for shot in shots:
                    if clip.id.lower() == shot.full_shot_name.lower():

                        # update with the given clip info
                        # anchor = shot.startFrame.get()
                        handle = shot.handle.get()
                        track = shot.track.get()

                        if shot in used_shots:
                            # this shot has been used once so duplicate it
                            # before doing anything
                            dup_shot = seq1.create_shot(shot.shotName.get())
                            dup_shot.startFrame.set(shot.startFrame.get())
                            dup_shot.endFrame.set(shot.endFrame.get())
                            dup_shot.handle.set(shot.handle.get())
                            dup_shot.sequenceStartFrame.set(
                                shot.sequenceStartFrame.get()
                            )
                            # do not copy sequenceEndFrame
                            # copy camera
                            dup_shot.set_camera(shot.get_camera())
                            dup_shot.anchor = shot.anchor
                            shot = dup_shot

                        start_frame = clip.in_ - handle + shot.anchor
                        end_frame = clip.out - clip.in_ + start_frame - 1

                        # print '-------------------------------'
                        # print 'clip.in     : %s' % clip.in_
                        # print 'clip.out    : %s' % clip.out
                        # print 'clip.start  : %s' % clip.start
                        # print 'clip.end    : %s' % clip.end
                        # print 'start_frame : %s' % start_frame
                        # print 'end_frame   : %s' % end_frame

                        sequence_start = clip.start

                        shot.startFrame.set(start_frame)
                        shot.endFrame.set(end_frame)

                        shot.sequenceStartFrame.set(sequence_start)

                        # set original track
                        shot.track.set(track)

                        used_shots.append(shot)
                        break

            for shot in seq1.shots.get():
                if shot not in used_shots:
                    deleted_shots.append(shot)

            # delete shots
            pm.delete(deleted_shots)

        else:
            # create sequencer
            seq1 = self.create_sequence(seq.name)

            # create shots
            media = seq.media
            for i, track in enumerate(media.video.tracks):
                for clip in track.clips:
                    # clip.id is something like SEQ001_HSNI_010_0010_v046
                    # filter the shot name
                    shot_name = clip.id.split('_')[-2]
                    shot = seq1.create_shot(shot_name)

                    shot.startFrame.set(clip.in_)
                    shot.endFrame.set(clip.out - 1)
                    shot.sequenceStartFrame.set(clip.start)
                    shot.handle.set(0)
                    if clip.file:
                        f = clip.file
                        pathurl = f.pathurl.replace('file://localhost/', '')
                        if ':' not in pathurl:  # not windows, keep '/'
                            pathurl = '/%s' % pathurl
                        shot.output.set(pathurl)

                    shot.track.set(i + 1)
dataset/ETHPy150Open eoyilmaz/anima/anima/env/mayaEnv/extension.py/SequenceManagerExtension.from_seq/original