[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2817] contrib/py/scripts/addons/ io_sequencer_edl/import_edl.py: tab -> spaces and pep8 cleanup, also some py3k compat edits

Campbell Barton ideasman42 at gmail.com
Wed Dec 28 07:58:15 CET 2011


Revision: 2817
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2817
Author:   campbellbarton
Date:     2011-12-28 06:58:07 +0000 (Wed, 28 Dec 2011)
Log Message:
-----------
tab -> spaces and pep8 cleanup, also some py3k compat edits

Modified Paths:
--------------
    contrib/py/scripts/addons/io_sequencer_edl/import_edl.py

Modified: contrib/py/scripts/addons/io_sequencer_edl/import_edl.py
===================================================================
--- contrib/py/scripts/addons/io_sequencer_edl/import_edl.py	2011-12-28 06:17:19 UTC (rev 2816)
+++ contrib/py/scripts/addons/io_sequencer_edl/import_edl.py	2011-12-28 06:58:07 UTC (rev 2817)
@@ -17,121 +17,140 @@
 # ##### END GPL LICENSE BLOCK #####
 
 # <pep8 compliant>
- 
+
 """
-Name: 'Video Sequence (.edl)...'
+Name: "Video Sequence (.edl)..."
 Blender: 248
-Group: 'Import'
-Tooltip: 'Load a CMX formatted EDL into the sequencer'
+Group: "Import"
+Tooltip: "Load a CMX formatted EDL into the sequencer"
 """
 
+
 class TimeCode(object):
-	'''
-	Simple timecode class
-	also supports conversion from other time strings used by EDL
-	'''
-	def __init__(self, data, fps):
-		self.fps= fps
-		if type(data)==str:
-			self.fromString(data)
-			frame = self.asFrame()
-			self.fromFrame(frame)
-		else:
-			self.fromFrame(data)
-		
-	def fromString(self, text):
-		# hh:mm:ss:ff
-		# No dropframe support yet
+    """
+    Simple timecode class
+    also supports conversion from other time strings used by EDL
+    """
+    def __init__(self, data, fps):
+        self.fps = fps
+        if type(data) == str:
+            self.fromString(data)
+            frame = self.asFrame()
+            self.fromFrame(frame)
+        else:
+            self.fromFrame(data)
 
-		if text.lower().endswith('mps'): # 5.2mps
-			return self.fromFrame( int( float(text[:-3]) * self.fps ) )
-		elif text.lower().endswith('s'): # 5.2s
-			return self.fromFrame( int( float(text[:-1]) * self.fps ) )
-		elif text.isdigit(): # 1234
-			return self.fromFrame( int(text) )
-		elif ':' in text: # hh:mm:ss:ff
-			text= text.replace(';', ':').replace(',', ':').replace('.', ':')
-			text= text.split(':')
-			
-			self.hours= int(text[0])
-			self.minutes= int(text[1])
-			self.seconds= int(text[2])
-			self.frame= int(text[3])
-			return self
-		else:
-			print('ERROR: could not convert this into timecode "%s"' % test)
-			return self
+    def fromString(self, text):
+        # hh:mm:ss:ff
+        # No dropframe support yet
 
-		
-	def fromFrame(self, frame):
-		
-		if frame < 0:
-			frame = -frame;
-			neg=True
-		else:
-			neg=False
-		
-		fpm = 60 * self.fps
-		fph = 60 * fpm
-		
-		if frame < fph:
-			self.hours= 0
-		else:
-			self.hours= int(frame/fph)
-			frame = frame % fph
-		
-		if frame < fpm:
-			self.minutes= 0
-		else:
-			self.minutes= int(frame/fpm)
-			frame = frame % fpm
-		
-		if frame < self.fps:
-			self.seconds= 0
-		else:
-			self.seconds= int(frame/self.fps)
-			frame = frame % self.fps
-		
-		self.frame= frame
-		
-		if neg:
-			self.frame = -self.frame
-			self.seconds = -self.seconds
-			self.minutes = -self.minutes
-			self.hours = -self.hours
-		
-		return self
-		
-	def asFrame(self):
-		abs_frame= self.frame
-		abs_frame += self.seconds * self.fps
-		abs_frame += self.minutes * 60 * self.fps
-		abs_frame += self.hours * 60 * 60 * self.fps
-		
-		return abs_frame
-	
-	def asString(self):
-		self.fromFrame(int(self))
-		return '%.2d:%.2d:%.2d:%.2d' % (self.hours, self.minutes, self.seconds, self.frame)
-	
-	def __repr__(self):
-		return self.asString()
-	
-	# Numeric stuff, may as well have this
-	def __neg__(self):			return TimeCode(-int(self), self.fps)
-	def __int__(self):			return self.asFrame()
-	def __sub__(self, other):		return TimeCode(int(self)-int(other), self.fps)
-	def __add__(self, other):		return TimeCode(int(self)+int(other), self.fps)
-	def __mul__(self, other):		return TimeCode(int(self)*int(other), self.fps)
-	def __div__(self, other):		return TimeCode(int(self)/int(other), self.fps)
-	def __abs__(self):			return TimeCode(abs(int(self)), self.fps)
-	def __iadd__(self, other):	return self.fromFrame(int(self)+int(other))
-	def __imul__(self, other):	return self.fromFrame(int(self)*int(other))
-	def __idiv__(self, other):		return self.fromFrame(int(self)/int(other))
+        if text.lower().endswith("mps"):  # 5.2mps
+            return self.fromFrame(int(float(text[:-3]) * self.fps))
+        elif text.lower().endswith("s"):  # 5.2s
+            return self.fromFrame(int(float(text[:-1]) * self.fps))
+        elif text.isdigit():  # 1234
+            return self.fromFrame(int(text))
+        elif ":" in text:  # hh:mm:ss:ff
+            text = text.replace(";", ":").replace(",", ":").replace(".", ":")
+            text = text.split(":")
+
+            self.hours = int(text[0])
+            self.minutes = int(text[1])
+            self.seconds = int(text[2])
+            self.frame = int(text[3])
+            return self
+        else:
+            print("ERROR: could not convert this into timecode %r" % test)
+            return self
+
+    def fromFrame(self, frame):
+
+        if frame < 0:
+            frame = -frame
+            neg = True
+        else:
+            neg = False
+
+        fpm = 60 * self.fps
+        fph = 60 * fpm
+
+        if frame < fph:
+            self.hours = 0
+        else:
+            self.hours = int(frame / fph)
+            frame = frame % fph
+
+        if frame < fpm:
+            self.minutes = 0
+        else:
+            self.minutes = int(frame / fpm)
+            frame = frame % fpm
+
+        if frame < self.fps:
+            self.seconds = 0
+        else:
+            self.seconds = int(frame / self.fps)
+            frame = frame % self.fps
+
+        self.frame = frame
+
+        if neg:
+            self.frame = -self.frame
+            self.seconds = -self.seconds
+            self.minutes = -self.minutes
+            self.hours = -self.hours
+
+        return self
+
+    def asFrame(self):
+        abs_frame = self.frame
+        abs_frame += self.seconds * self.fps
+        abs_frame += self.minutes * 60 * self.fps
+        abs_frame += self.hours * 60 * 60 * self.fps
+
+        return abs_frame
+
+    def asString(self):
+        self.fromFrame(int(self))
+        return "%.2d:%.2d:%.2d:%.2d" % (self.hours, self.minutes, self.seconds, self.frame)
+
+    def __repr__(self):
+        return self.asString()
+
+    # Numeric stuff, may as well have this
+    def __neg__(self):
+        return TimeCode(-int(self), self.fps)
+
+    def __int__(self):
+        return self.asFrame()
+
+    def __sub__(self, other):
+        return TimeCode(int(self) - int(other), self.fps)
+
+    def __add__(self, other):
+        return TimeCode(int(self) + int(other), self.fps)
+
+    def __mul__(self, other):
+        return TimeCode(int(self) * int(other), self.fps)
+
+    def __div__(self, other):
+        return TimeCode(int(self) // int(other), self.fps)
+
+    def __abs__(self):
+        return TimeCode(abs(int(self)), self.fps)
+
+    def __iadd__(self, other):
+        return self.fromFrame(int(self) + int(other))
+
+    def __imul__(self, other):
+        return self.fromFrame(int(self) * int(other))
+
+    def __idiv__(self, other):
+        return self.fromFrame(int(self) // int(other))
 # end timecode
 
 
-'''Comments
+"""Comments
 Comments can appear at the beginning of the EDL file (header) or between the edit lines in the EDL. The first block of comments in the file is defined to be the header comments and they are associated with the EDL as a whole. Subsequent comments in the EDL file are associated with the first edit line that appears after them.
 Edit Entries
 <filename|tag>  <EditMode>  <TransitionType>[num]  [duration]  [srcIn]  [srcOut]  [recIn]  [recOut]
@@ -144,7 +163,7 @@
     * [srcIn]: Src in. If no srcIn is given, then it defaults to the first frame of the video or the first frame in the image pattern. If srcIn isn't specified, then srcOut, recIn, recOut can't be specified.
     * [srcOut]: Src out. If no srcOut is given, then it defaults to the last frame of the video - or last image in the image pattern. if srcOut isn't given, then recIn and recOut can't be specified.
     * [recIn]: Rec in. If no recIn is given, then it is calculated based on its position in the EDL and the length of its input.
-      [recOut]: Rec out. If no recOut is given, then it is calculated based on its position in the EDL and the length of its input. first frame of the video. 
+      [recOut]: Rec out. If no recOut is given, then it is calculated based on its position in the EDL and the length of its input. first frame of the video.
 
 For srcIn, srcOut, recIn, recOut, the values can be specified as either timecode, frame number, seconds, or mps seconds. i.e.
 [tcode | fnum | sec | mps], where:
@@ -154,60 +173,77 @@
     * sec : seconds with 's' suffix (e.g. 5.2s)
     * mps : seconds with 'mps' suffix (e.g. 5.2mps). This corresponds to the 'seconds' value displayed by Windows MediaPlayer.
 
-More notes, 
+More notes,
 Key
-	
-'''
 
-enum= 0
-TRANSITION_UNKNOWN= enum
-TRANSITION_CUT= enum;				enum+=1
-TRANSITION_DISSOLVE= enum;			enum+=1
-TRANSITION_EFFECT= enum;			enum+=1
-TRANSITION_FADEIN= enum;			enum+=1
-TRANSITION_FADEOUT= enum;			enum+=1
-TRANSITION_WIPE= enum;				enum+=1
-TRANSITION_KEY= enum;				enum+=1
+"""
 
-TRANSITION_DICT={ \
-				'c':TRANSITION_CUT,
-				'd':TRANSITION_DISSOLVE,
-				'e':TRANSITION_EFFECT,
-				'fi':TRANSITION_FADEIN,
-				'fo':TRANSITION_FADEOUT,
-				'w':TRANSITION_WIPE,
-				'k':TRANSITION_KEY,
-				}
+enum = 0
+TRANSITION_UNKNOWN = enum
+TRANSITION_CUT = enum
+enum += 1
+TRANSITION_DISSOLVE = enum
+enum += 1
+TRANSITION_EFFECT = enum
+enum += 1
+TRANSITION_FADEIN = enum
+enum += 1
+TRANSITION_FADEOUT = enum
+enum += 1
+TRANSITION_WIPE = enum
+enum += 1
+TRANSITION_KEY = enum
+enum += 1
 
-enum= 0
-EDIT_UNKNOWN= 				1<<enum; enum+=1
-EDIT_VIDEO= 				1<<enum; enum+=1
-EDIT_AUDIO= 				1<<enum; enum+=1
-EDIT_AUDIO_STEREO=			1<<enum; enum+=1
-EDIT_VIDEO_AUDIO=			1<<enum; enum+=1
+TRANSITION_DICT = {
+    "c": TRANSITION_CUT,
+    "d": TRANSITION_DISSOLVE,
+    "e": TRANSITION_EFFECT,
+    "fi": TRANSITION_FADEIN,
+    "fo": TRANSITION_FADEOUT,
+    "w": TRANSITION_WIPE,
+    "k": TRANSITION_KEY,
+    }
 
-EDIT_DICT=		{ \
-				'v':EDIT_VIDEO,
-				'a':EDIT_AUDIO,
-				'aa':EDIT_AUDIO_STEREO,
-				'va':EDIT_VIDEO_AUDIO,
-				'b':EDIT_VIDEO_AUDIO
-				}
+enum = 0
+EDIT_UNKNOWN = 1 << enum
+enum += 1
+EDIT_VIDEO = 1 << enum
+enum += 1
+EDIT_AUDIO = 1 << enum
+enum += 1
+EDIT_AUDIO_STEREO = 1 << enum
+enum += 1
+EDIT_VIDEO_AUDIO = 1 << enum
+enum += 1
 
+EDIT_DICT = {
+    "v": EDIT_VIDEO,
+    "a": EDIT_AUDIO,
+    "aa": EDIT_AUDIO_STEREO,
+    "va": EDIT_VIDEO_AUDIO,
+    "b": EDIT_VIDEO_AUDIO,
+    }
 
-enum= 0
-WIPE_UNKNOWN= enum
-WIPE_0= enum;					enum+=1
-WIPE_1= enum;					enum+=1
 
-enum= 0

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list