[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1474] trunk/py/scripts/addons/ render_povray/render.py: conform to blender convention, "" for strings, '' for enum id's only.

Campbell Barton ideasman42 at gmail.com
Sat Jan 22 07:09:37 CET 2011


Revision: 1474
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1474
Author:   campbellbarton
Date:     2011-01-22 06:09:36 +0000 (Sat, 22 Jan 2011)
Log Message:
-----------
conform to blender convention, "" for strings, '' for enum id's only.

Modified Paths:
--------------
    trunk/py/scripts/addons/render_povray/render.py

Modified: trunk/py/scripts/addons/render_povray/render.py
===================================================================
--- trunk/py/scripts/addons/render_povray/render.py	2011-01-22 05:43:40 UTC (rev 1473)
+++ trunk/py/scripts/addons/render_povray/render.py	2011-01-22 06:09:36 UTC (rev 1474)
@@ -27,7 +27,7 @@
 from math import atan, pi, degrees, sqrt
 
 import platform as pltfrm
-if pltfrm.architecture()[0] == '64bit':
+if pltfrm.architecture()[0] == "64bit":
     bitness = 64
 else:
     bitness = 32
@@ -36,40 +36,40 @@
 ##############################SF###########################
 ##############find image texture
 def splitExt(path):
-    dotidx = path.rfind('.')
+    dotidx = path.rfind(".")
     if dotidx == -1:
-        return path, ''
+        return path, ""
     else:
         return path[dotidx:].upper().replace(".", "")
 
 
 def imageFormat(imgF):
-    ext = ''
+    ext = ""
     ext_orig = splitExt(imgF)
     if ext_orig == 'JPG' or ext_orig == 'JPEG':
-        ext = 'jpeg'
+        ext = "jpeg"
     elif ext_orig == 'GIF':
-        ext = 'gif'
+        ext = "gif"
     elif ext_orig == 'TGA':
-        ext = 'tga'
+        ext = "tga"
     elif ext_orig == 'IFF':
-        ext = 'iff'
+        ext = "iff"
     elif ext_orig == 'PPM':
-        ext = 'ppm'
+        ext = "ppm"
     elif ext_orig == 'PNG':
-        ext = 'png'
+        ext = "png"
     elif ext_orig == 'SYS':
-        ext = 'sys'
+        ext = "sys"
     elif ext_orig in ('TIFF', 'TIF'):
-        ext = 'tiff'
+        ext = "tiff"
     elif ext_orig == 'EXR':
-        ext = 'exr'  # POV3.7 Only!
+        ext = "exr"  # POV3.7 Only!
     elif ext_orig == 'HDR':
-        ext = 'hdr'  # POV3.7 Only! --MR
+        ext = "hdr"  # POV3.7 Only! --MR
 
     print(imgF)
     if not ext:
-        print(" WARNING: texture image  format not supported ")  # % (imgF , '')) #(ext_orig)))
+        print(" WARNING: texture image  format not supported ")  # % (imgF , "")) #(ext_orig)))
 
     return ext
 
@@ -82,17 +82,19 @@
         image_map = "map_type 1 "  # map_type 7 in megapov
     elif ts.mapping == 'TUBE':
         image_map = "map_type 2 "
-    #if ts.mapping=='?':image_map= ' map_type 3 '# map_type 3 and 4 in development (?) for POV-Ray, currently they just seem to default back to Flat (type 0)
-    #if ts.mapping=='?':image_map= ' map_type 4 '# map_type 3 and 4 in development (?) for POV-Ray, currently they just seem to default back to Flat (type 0)
+    #elif ts.mapping=="?":
+    #    image_map = " map_type 3 "  # map_type 3 and 4 in development (?) for POV-Ray, currently they just seem to default back to Flat (type 0)
+    #elif ts.mapping=="?":
+    #    image_map = " map_type 4 "  # map_type 3 and 4 in development (?) for POV-Ray, currently they just seem to default back to Flat (type 0)
     if ts.texture.use_interpolation:
         image_map += " interpolate 2 "
     if ts.texture.extension == 'CLIP':
         image_map += " once "
     #image_map += "}"
     #if ts.mapping=='CUBE':
-    #    image_map+= 'warp { cubic } rotate <-90,0,180>' #no direct cube type mapping. Though this should work in POV 3.7 it doesn't give that good results(best suited to environment maps?)
+    #    image_map+= "warp { cubic } rotate <-90,0,180>"  # no direct cube type mapping. Though this should work in POV 3.7 it doesn't give that good results(best suited to environment maps?)
     #if image_map == "":
-    #    print(' No texture image  found ')
+    #    print(" No texture image  found ")
     return image_map
 
 
@@ -109,23 +111,25 @@
         image_mapBG += " interpolate 2 "
     if wts.texture.extension == 'CLIP':
         image_mapBG += " once "
-    #image_mapBG+='}'
-    #if wts.mapping=='CUBE':image_mapBG+= 'warp { cubic } rotate <-90,0,180>' #no direct cube type mapping. Though this should work in POV 3.7 it doesn't give that good results(best suited to environment maps?)
-    #if image_mapBG== "": print(' No background texture image  found ')
+    #image_mapBG += "}"
+    #if wts.mapping == 'CUBE':
+    #   image_mapBG += "warp { cubic } rotate <-90,0,180>"  # no direct cube type mapping. Though this should work in POV 3.7 it doesn't give that good results(best suited to environment maps?)
+    #if image_mapBG == "":
+    #    print(" No background texture image  found ")
     return image_mapBG
 
 
 def splitFile(path):
-    idx = path.rfind('/')
+    idx = path.rfind("/")
     if idx == -1:
-        idx = path.rfind('\\')
-    return path[idx:].replace('/', '').replace('\\', '')
+        idx = path.rfind("\\")
+    return path[idx:].replace("/", "").replace("\\", "")
 
 
 def splitPath(path):
-    idx = path.rfind('/')
+    idx = path.rfind("/")
     if idx == -1:
-        return path, ''
+        return path, ""
     else:
         return path[:idx]
 
@@ -142,7 +146,7 @@
                 pahFile = os.path.join(root, filename)
         return pahFile
     except OSError:
-        return ''
+        return ""
 
 
 def path_image(image):
@@ -157,7 +161,7 @@
 
 
 def splitHyphen(name):
-    hyphidx = name.find('-')
+    hyphidx = name.find("-")
     if hyphidx == -1:
         return name
     else:
@@ -175,7 +179,7 @@
         if int(name) > 0:
             prefix = "shader"
     except:
-        prefix = ''
+        prefix = ""
     prefix = "shader_"
     name = splitHyphen(name)
     if Level == 2:
@@ -195,7 +199,7 @@
 def write_pov(filename, scene=None, info_callback=None):
     import mathutils
     #file = filename
-    file = open(filename.name, 'w')
+    file = open(filename.name, "w")
 
     # Only for testing
     if not scene:
@@ -206,27 +210,27 @@
     global_matrix = mathutils.Matrix.Rotation(-pi / 2.0, 4, 'X')
 
     def setTab(tabtype, spaces):
-        TabStr = ''
+        TabStr = ""
         if tabtype == '0':
-            TabStr = ''
+            TabStr = ""
         elif tabtype == '1':
-            TabStr = '\t'
+            TabStr = "\t"
         elif tabtype == '2':
-            TabStr = spaces * ' '
+            TabStr = spaces * " "
         return TabStr
 
     Tab = setTab(scene.pov_indentation_character, scene.pov_indentation_spaces)
 
     def tabWrite(str_o):
         global TabLevel
-        brackets = str_o.count('{') - str_o.count('}') + str_o.count('[') - str_o.count(']')
+        brackets = str_o.count("{") - str_o.count("}") + str_o.count("[") - str_o.count("]")
         if brackets < 0:
             TabLevel = TabLevel + brackets
         if TabLevel < 0:
-            print('Indentation Warning: TabLevel = %s' % TabLevel)
+            print("Indentation Warning: TabLevel = %s" % TabLevel)
             TabLevel = 0
         if TabLevel >= 1:
-            file.write('%s' % Tab * TabLevel)
+            file.write("%s" % Tab * TabLevel)
         file.write(str_o)
         if brackets > 0:
             TabLevel = TabLevel + brackets
@@ -239,13 +243,13 @@
         name_orig = name
         i = 1
         while name in nameSeq:
-            name = '%s_%.3d' % (name_orig, i)
+            name = "%s_%.3d" % (name_orig, i)
             i += 1
         name = splitHyphen(name)
         return name
 
     def writeMatrix(matrix):
-        tabWrite('matrix <%.6f, %.6f, %.6f,  %.6f, %.6f, %.6f,  %.6f, %.6f, %.6f,  %.6f, %.6f, %.6f>\n' %\
+        tabWrite("matrix <%.6f, %.6f, %.6f,  %.6f, %.6f, %.6f,  %.6f, %.6f, %.6f,  %.6f, %.6f, %.6f>\n" %\
         (matrix[0][0], matrix[0][1], matrix[0][2], matrix[1][0], matrix[1][1], matrix[1][2], matrix[2][0], matrix[2][1], matrix[2][2], matrix[3][0], matrix[3][1], matrix[3][2]))
 
     def writeObjectMaterial(material):
@@ -253,17 +257,17 @@
         # DH - modified some variables to be function local, avoiding RNA write
         # this should be checked to see if it is functionally correct
 
-        if material:  # and material.transparency_method == 'RAYTRACE':#Commented out: always write IOR to be able to use it for SSS, Fresnel reflections...
+        if material:  # and material.transparency_method == 'RAYTRACE':  # Commented out: always write IOR to be able to use it for SSS, Fresnel reflections...
             # But there can be only one!
             if material.subsurface_scattering.use:  # SSS IOR get highest priority
-                tabWrite('interior {\n')
-                tabWrite('ior %.6f\n' % material.subsurface_scattering.ior)
+                tabWrite("interior {\n")
+                tabWrite("ior %.6f\n" % material.subsurface_scattering.ior)
             elif material.pov_mirror_use_IOR:  # Then the raytrace IOR taken from raytrace transparency properties and used for reflections if IOR Mirror option is checked
-                tabWrite('interior {\n')
-                tabWrite('ior %.6f\n' % material.raytrace_transparency.ior)
+                tabWrite("interior {\n")
+                tabWrite("ior %.6f\n" % material.raytrace_transparency.ior)
             else:
-                tabWrite('interior {\n')
-                tabWrite('ior %.6f\n' % material.raytrace_transparency.ior)
+                tabWrite("interior {\n")
+                tabWrite("ior %.6f\n" % material.raytrace_transparency.ior)
 
             pov_fake_caustics = False
             pov_photons_refraction = False
@@ -284,9 +288,9 @@
             #Last, if none of the above is specified, user can set up 'un-physical' fresnel reflections in raytrace mirror parameters. And pov IOR defaults to 1.
             if material.pov_caustics_enable:
                 if pov_fake_caustics:
-                    tabWrite('caustics %.3g\n' % material.pov_fake_caustics_power)
+                    tabWrite("caustics %.3g\n" % material.pov_fake_caustics_power)
                 if pov_photons_refraction:
-                    tabWrite('dispersion %.3g\n' % material.pov_photons_dispersion)  # Default of 1 means no dispersion
+                    tabWrite("dispersion %.3g\n" % material.pov_photons_dispersion)  # Default of 1 means no dispersion
             #TODO
             # Other interior args
             # if material.use_transparency and material.transparency_method == 'RAYTRACE':
@@ -295,18 +299,18 @@
             # fade_color
 
             # (variable) dispersion_samples (constant count for now)
-            tabWrite('}\n')
+            tabWrite("}\n")
             if pov_photons_refraction or pov_photons_reflection:
-                tabWrite('photons{\n')
-                tabWrite('target\n')
+                tabWrite("photons{\n")
+                tabWrite("target\n")

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list