[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1992] trunk/py/scripts/addons/ io_scene_x3d/export_x3d.py: switch quoting not to do \" all over.

Campbell Barton ideasman42 at gmail.com
Thu Jun 2 03:59:47 CEST 2011


Revision: 1992
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1992
Author:   campbellbarton
Date:     2011-06-02 01:59:46 +0000 (Thu, 02 Jun 2011)
Log Message:
-----------
switch quoting not to do \" all over.

Modified Paths:
--------------
    trunk/py/scripts/addons/io_scene_x3d/export_x3d.py

Modified: trunk/py/scripts/addons/io_scene_x3d/export_x3d.py
===================================================================
--- trunk/py/scripts/addons/io_scene_x3d/export_x3d.py	2011-06-02 01:25:06 UTC (rev 1991)
+++ trunk/py/scripts/addons/io_scene_x3d/export_x3d.py	2011-06-02 01:59:46 UTC (rev 1992)
@@ -41,32 +41,32 @@
 
 from bpy_extras.io_utils import create_derived_objects, free_derived_objects
 
-x3d_names_reserved = {"Anchor", "Appearance", "Arc2D", "ArcClose2D", "AudioClip", "Background", "Billboard",
-                      "BooleanFilter", "BooleanSequencer", "BooleanToggle", "BooleanTrigger", "Box", "Circle2D",
-                      "Collision", "Color", "ColorInterpolator", "ColorRGBA", "component", "Cone", "connect",
-                      "Contour2D", "ContourPolyline2D", "Coordinate", "CoordinateDouble", "CoordinateInterpolator",
-                      "CoordinateInterpolator2D", "Cylinder", "CylinderSensor", "DirectionalLight", "Disk2D",
-                      "ElevationGrid", "EspduTransform", "EXPORT", "ExternProtoDeclare", "Extrusion", "field",
-                      "fieldValue", "FillProperties", "Fog", "FontStyle", "GeoCoordinate", "GeoElevationGrid",
-                      "GeoLocationLocation", "GeoLOD", "GeoMetadata", "GeoOrigin", "GeoPositionInterpolator",
-                      "GeoTouchSensor", "GeoViewpoint", "Group", "HAnimDisplacer", "HAnimHumanoid", "HAnimJoint",
-                      "HAnimSegment", "HAnimSite", "head", "ImageTexture", "IMPORT", "IndexedFaceSet",
-                      "IndexedLineSet", "IndexedTriangleFanSet", "IndexedTriangleSet", "IndexedTriangleStripSet",
-                      "Inline", "IntegerSequencer", "IntegerTrigger", "IS", "KeySensor", "LineProperties", "LineSet",
-                      "LoadSensor", "LOD", "Material", "meta", "MetadataDouble", "MetadataFloat", "MetadataInteger",
-                      "MetadataSet", "MetadataString", "MovieTexture", "MultiTexture", "MultiTextureCoordinate",
-                      "MultiTextureTransform", "NavigationInfo", "Normal", "NormalInterpolator", "NurbsCurve",
-                      "NurbsCurve2D", "NurbsOrientationInterpolator", "NurbsPatchSurface",
-                      "NurbsPositionInterpolator", "NurbsSet", "NurbsSurfaceInterpolator", "NurbsSweptSurface",
-                      "NurbsSwungSurface", "NurbsTextureCoordinate", "NurbsTrimmedSurface", "OrientationInterpolator",
-                      "PixelTexture", "PlaneSensor", "PointLight", "PointSet", "Polyline2D", "Polypoint2D",
-                      "PositionInterpolator", "PositionInterpolator2D", "ProtoBody", "ProtoDeclare", "ProtoInstance",
-                      "ProtoInterface", "ProximitySensor", "ReceiverPdu", "Rectangle2D", "ROUTE", "ScalarInterpolator",
-                      "Scene", "Script", "Shape", "SignalPdu", "Sound", "Sphere", "SphereSensor", "SpotLight", "StaticGroup",
-                      "StringSensor", "Switch", "Text", "TextureBackground", "TextureCoordinate", "TextureCoordinateGenerator",
-                      "TextureTransform", "TimeSensor", "TimeTrigger", "TouchSensor", "Transform", "TransmitterPdu",
-                      "TriangleFanSet", "TriangleSet", "TriangleSet2D", "TriangleStripSet", "Viewpoint", "VisibilitySensor",
-                      "WorldInfo", "X3D", "XvlShell", "VertexShader", "FragmentShader", "MultiShaderAppearance", "ShaderAppearance"}
+x3d_names_reserved = {'Anchor', 'Appearance', 'Arc2D', 'ArcClose2D', 'AudioClip', 'Background', 'Billboard',
+                      'BooleanFilter', 'BooleanSequencer', 'BooleanToggle', 'BooleanTrigger', 'Box', 'Circle2D',
+                      'Collision', 'Color', 'ColorInterpolator', 'ColorRGBA', 'component', 'Cone', 'connect',
+                      'Contour2D', 'ContourPolyline2D', 'Coordinate', 'CoordinateDouble', 'CoordinateInterpolator',
+                      'CoordinateInterpolator2D', 'Cylinder', 'CylinderSensor', 'DirectionalLight', 'Disk2D',
+                      'ElevationGrid', 'EspduTransform', 'EXPORT', 'ExternProtoDeclare', 'Extrusion', 'field',
+                      'fieldValue', 'FillProperties', 'Fog', 'FontStyle', 'GeoCoordinate', 'GeoElevationGrid',
+                      'GeoLocationLocation', 'GeoLOD', 'GeoMetadata', 'GeoOrigin', 'GeoPositionInterpolator',
+                      'GeoTouchSensor', 'GeoViewpoint', 'Group', 'HAnimDisplacer', 'HAnimHumanoid', 'HAnimJoint',
+                      'HAnimSegment', 'HAnimSite', 'head', 'ImageTexture', 'IMPORT', 'IndexedFaceSet',
+                      'IndexedLineSet', 'IndexedTriangleFanSet', 'IndexedTriangleSet', 'IndexedTriangleStripSet',
+                      'Inline', 'IntegerSequencer', 'IntegerTrigger', 'IS', 'KeySensor', 'LineProperties', 'LineSet',
+                      'LoadSensor', 'LOD', 'Material', 'meta', 'MetadataDouble', 'MetadataFloat', 'MetadataInteger',
+                      'MetadataSet', 'MetadataString', 'MovieTexture', 'MultiTexture', 'MultiTextureCoordinate',
+                      'MultiTextureTransform', 'NavigationInfo', 'Normal', 'NormalInterpolator', 'NurbsCurve',
+                      'NurbsCurve2D', 'NurbsOrientationInterpolator', 'NurbsPatchSurface',
+                      'NurbsPositionInterpolator', 'NurbsSet', 'NurbsSurfaceInterpolator', 'NurbsSweptSurface',
+                      'NurbsSwungSurface', 'NurbsTextureCoordinate', 'NurbsTrimmedSurface', 'OrientationInterpolator',
+                      'PixelTexture', 'PlaneSensor', 'PointLight', 'PointSet', 'Polyline2D', 'Polypoint2D',
+                      'PositionInterpolator', 'PositionInterpolator2D', 'ProtoBody', 'ProtoDeclare', 'ProtoInstance',
+                      'ProtoInterface', 'ProximitySensor', 'ReceiverPdu', 'Rectangle2D', 'ROUTE', 'ScalarInterpolator',
+                      'Scene', 'Script', 'Shape', 'SignalPdu', 'Sound', 'Sphere', 'SphereSensor', 'SpotLight', 'StaticGroup',
+                      'StringSensor', 'Switch', 'Text', 'TextureBackground', 'TextureCoordinate', 'TextureCoordinateGenerator',
+                      'TextureTransform', 'TimeSensor', 'TimeTrigger', 'TouchSensor', 'Transform', 'TransmitterPdu',
+                      'TriangleFanSet', 'TriangleSet', 'TriangleSet2D', 'TriangleStripSet', 'Viewpoint', 'VisibilitySensor',
+                      'WorldInfo', 'X3D', 'XvlShell', 'VertexShader', 'FragmentShader', 'MultiShaderAppearance', 'ShaderAppearance'}
 
 
 def clamp_color(col):
@@ -86,10 +86,10 @@
         newName = '%s%s' % (prefix, newName)
 
     if newName[0].isdigit():
-        newName = "%s%s" % ("_", newName)
+        newName = '%s%s' % ('_', newName)
 
     for bad in [' ', '"', '#', "'", ', ', '.', '[', '\\', ']', '{', '}']:
-        newName = newName.replace(bad, "_")
+        newName = newName.replace(bad, '_')
     return newName
 
 
@@ -115,7 +115,7 @@
 
     if use_h3d:
         import gpu
-        gpu_shader_dummy_mat = bpy.data.materials.new("X3D_DYMMY_MAT")
+        gpu_shader_dummy_mat = bpy.data.materials.new('X3D_DYMMY_MAT')
         gpu_shader_cache[None] = gpu.export_shader(scene, gpu_shader_dummy_mat)
 
 
@@ -127,41 +127,41 @@
         filepath = fw.__self__.name
         #bfile = sys.expandpath( Blender.Get('filepath') ).replace('<', '&lt').replace('>', '&gt')
         bfile = repr(os.path.basename(filepath).replace('<', '&lt').replace('>', '&gt'))[1:-1]  # use outfile name
-        fw("%s<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" % ident)
+        fw('%s<?xml version="1.0" encoding="UTF-8"?>\n' % ident)
         if use_h3d:
-            fw("%s<X3D profile=\"H3DAPI\" version=\"1.4\">\n" % ident)
+            fw('%s<X3D profile="H3DAPI" version="1.4">\n' % ident)
         else:
-            fw("%s<!DOCTYPE X3D PUBLIC \"ISO//Web3D//DTD X3D 3.0//EN\" \"http://www.web3d.org/specifications/x3d-3.0.dtd\">\n" % ident)
-            fw("%s<X3D version=\"3.0\" profile=\"Immersive\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema-instance\" xsd:noNamespaceSchemaLocation=\"http://www.web3d.org/specifications/x3d-3.0.xsd\">\n" % ident)
+            fw('%s<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd">\n' % ident)
+            fw('%s<X3D version="3.0" profile="Immersive" xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="http://www.web3d.org/specifications/x3d-3.0.xsd">\n' % ident)
 
-        ident += "\t"
-        fw("%s<head>\n" % ident)
-        ident += "\t"
-        fw("%s<meta name=\"filename\" content=\"%s\" />\n" % (ident, bfile))
-        fw("%s<meta name=\"generator\" content=\"Blender %s\" />\n" % (ident, bpy.app.version_string))
-        fw("%s<meta name=\"translator\" content=\"X3D exporter v1.55 (2006/01/17)\" />\n" % ident)
+        ident += '\t'
+        fw('%s<head>\n' % ident)
+        ident += '\t'
+        fw('%s<meta name="filename" content="%s" />\n' % (ident, bfile))
+        fw('%s<meta name="generator" content="Blender %s" />\n' % (ident, bpy.app.version_string))
+        fw('%s<meta name="translator" content="X3D exporter v1.55 (2006/01/17)" />\n' % ident)
         ident = ident[:-1]
-        fw("%s</head>\n" % ident)
-        fw("%s<Scene>\n" % ident)
-        ident += "\t"
+        fw('%s</head>\n' % ident)
+        fw('%s<Scene>\n' % ident)
+        ident += '\t'
         return ident
 
     def writeFooter(ident):
         ident = ident[:-1]
-        fw("%s</Scene>\n" % ident)
+        fw('%s</Scene>\n' % ident)
         ident = ident[:-1]
-        fw("%s</X3D>" % ident)
+        fw('%s</X3D>' % ident)
         return ident
 
     def writeViewpoint(ident, ob, mat, scene):
         loc, quat, scale = mat.decompose()
-        fw("%s<Viewpoint DEF=\"%s\" " % (ident, clean_str(ob.name)))
-        fw("description=\"%s\" " % ob.name)
-        fw("centerOfRotation=\"0 0 0\" ")
-        fw("position=\"%3.2f %3.2f %3.2f\" " % loc[:])
-        fw("orientation=\"%3.2f %3.2f %3.2f %3.2f\" " % (quat.axis[:] + (quat.angle, )))
-        fw("fieldOfView=\"%.3g\" " % ob.data.angle)
-        fw(" />\n")
+        fw('%s<Viewpoint DEF="%s" ' % (ident, clean_str(ob.name)))
+        fw('description="%s" ' % ob.name)
+        fw('centerOfRotation="0 0 0" ')
+        fw('position="%3.2f %3.2f %3.2f" ' % loc[:])
+        fw('orientation="%3.2f %3.2f %3.2f %3.2f" ' % (quat.axis[:] + (quat.angle, )))

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list