How to use writelines method in green

Best Python code snippet using green

generate_single.py

Source:generate_single.py Github

copy

Full Screen

...19 elif (yarnType=='yarn100'):20 isYarn100=121 with open(xmlfile, "w") as fout:22 23 fout.writelines("<?xml version='1.0' encoding='utf-8'?>\n")24 fout.writelines('<scene version="0.4.4"> \n')25 26 fout.writelines('\t<integrator type="volpath"> \n')27 fout.writelines('\t\t<integer name="maxDepth" value="25"/> \n')28 fout.writelines('\t\t<integer name="rrDepth" value="30"/> \n')29 fout.writelines('\t</integrator> \n')30 fout.writelines('\n') 31 32 if (isYarn8):33 #### cylinders 1.2 0011034 fout.writelines('\t<shape type="cylinder">\n')35 fout.writelines('\t\t<float name="radius" value="0.16"/>\n')36 fout.writelines('\t\t<point name="p0" x="-0.1" y="$h2" z="0"/>\n')37 fout.writelines('\t\t<point name="p1" x="0.7" y="$h2" z="0"/>\n')38 fout.writelines('\t\t<bsdf type="diffuse">\n')39 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.3"/>\n')40 fout.writelines('\t\t</bsdf> \n')41 fout.writelines('\t</shape>\n')42 fout.writelines('\t<shape type="cylinder">\n')43 fout.writelines('\t\t<float name="radius" value="0.16"/>\n')44 fout.writelines('\t\t<point name="p0" x="-0.1" y="$h2" z="0.48"/>\n')45 fout.writelines('\t\t<point name="p1" x="0.7" y="$h2" z="0.48"/>\n')46 fout.writelines('\t\t<bsdf type="diffuse">\n')47 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.3"/>\n')48 fout.writelines('\t\t</bsdf> \n')49 fout.writelines('\t</shape>\n')50 fout.writelines('\t<shape type="cylinder">\n')51 fout.writelines('\t\t<float name="radius" value="0.16"/>\n')52 fout.writelines('\t\t<point name="p0" x="-0.1" y="$h2" z="-0.48"/>\n')53 fout.writelines('\t\t<point name="p1" x="0.7" y="$h2" z="-0.48"/>\n')54 fout.writelines('\t\t<bsdf type="diffuse">\n')55 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.3"/>\n')56 fout.writelines('\t\t</bsdf> \n')57 fout.writelines('\t</shape>\n')58 fout.writelines('\t<shape type="cylinder">\n')59 fout.writelines('\t\t<float name="radius" value="0.16"/>\n')60 fout.writelines('\t\t<point name="p0" x="-0.1" y="$h1" z="0.96"/>\n')61 fout.writelines('\t\t<point name="p1" x="0.7" y="$h1" z="0.96"/>\n')62 fout.writelines('\t\t<bsdf type="diffuse">\n')63 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.3"/>\n')64 fout.writelines('\t\t</bsdf> \n')65 fout.writelines('\t</shape>\n')66 fout.writelines('\t<shape type="cylinder">\n')67 fout.writelines('\t\t<float name="radius" value="0.16"/>\n')68 fout.writelines('\t\t<point name="p0" x="-0.1" y="$h1" z="-0.96"/>\n')69 fout.writelines('\t\t<point name="p1" x="0.7" y="$h1" z="-0.96"/>\n')70 fout.writelines('\t\t<bsdf type="diffuse">\n')71 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.3"/>\n')72 fout.writelines('\t\t</bsdf> \n')73 fout.writelines('\t</shape>\n')74 75 fout.writelines('\t<shape type="disk">\n')76 fout.writelines('\t\t<transform name="toWorld">\n')77 fout.writelines('\t\t\t<rotate y="1" angle="-90"/>\n')78 fout.writelines('\t\t\t<scale value="0.16"/>\n')79 fout.writelines('\t\t\t<translate x="-0.1" y="$h2" z="0"/>\n')80 fout.writelines('\t\t</transform>\n')81 fout.writelines('\t\t<bsdf type="diffuse">\n')82 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.3"/>\n')83 fout.writelines('\t\t</bsdf>\n')84 fout.writelines('\t</shape>\n')85 86 fout.writelines('\t<shape type="disk">\n')87 fout.writelines('\t\t<transform name="toWorld">\n')88 fout.writelines('\t\t\t<rotate y="1" angle="-90"/>\n')89 fout.writelines('\t\t\t<scale value="0.16"/>\n')90 fout.writelines('\t\t\t<translate x="-0.1" y="$h2" z="0.48"/>\n')91 fout.writelines('\t\t</transform>\n')92 fout.writelines('\t\t<bsdf type="diffuse">\n')93 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.3"/>\n')94 fout.writelines('\t\t</bsdf>\n')95 fout.writelines('\t</shape>\n')96 97 fout.writelines('\t<shape type="disk">\n')98 fout.writelines('\t\t<transform name="toWorld">\n')99 fout.writelines('\t\t\t<rotate y="1" angle="-90"/>\n')100 fout.writelines('\t\t\t<scale value="0.16"/>\n')101 fout.writelines('\t\t\t<translate x="-0.1" y="$h2" z="-0.48"/>\n')102 fout.writelines('\t\t</transform>\n')103 fout.writelines('\t\t<bsdf type="diffuse">\n')104 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.3"/>\n')105 fout.writelines('\t\t</bsdf>\n')106 fout.writelines('\t</shape>\n')107 108 fout.writelines('\t<shape type="disk">\n')109 fout.writelines('\t\t<transform name="toWorld">\n')110 fout.writelines('\t\t\t<rotate y="1" angle="-90"/>\n')111 fout.writelines('\t\t\t<scale value="0.16"/>\n')112 fout.writelines('\t\t\t<translate x="-0.1" y="$h1" z="0.96"/>\n')113 fout.writelines('\t\t</transform>\n')114 fout.writelines('\t\t<bsdf type="diffuse">\n')115 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.3"/>\n')116 fout.writelines('\t\t</bsdf>\n')117 118 fout.writelines('\t</shape>\n')119 fout.writelines('\t<shape type="disk">\n')120 fout.writelines('\t\t<transform name="toWorld">\n')121 fout.writelines('\t\t\t<rotate y="1" angle="-90"/>\n')122 fout.writelines('\t\t\t<scale value="0.16"/>\n')123 fout.writelines('\t\t\t<translate x="-0.1" y="$h1" z="-0.96"/>\n')124 fout.writelines('\t\t</transform>\n')125 fout.writelines('\t\t<bsdf type="diffuse">\n')126 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.3"/>\n')127 fout.writelines('\t\t</bsdf>\n')128 fout.writelines('\t</shape>\n')129 130 if (isYarn11):131 #### cylinder 1.6132 fout.writelines('\t<shape type="cylinder">\n')133 fout.writelines('\t\t<float name="radius" value="0.16"/>\n')134 fout.writelines('\t\t<point name="p0" x="-0.1" y="$h1" z="0"/>\n')135 fout.writelines('\t\t<point name="p1" x="0.7" y="$h1" z="0"/>\n')136 fout.writelines('\t\t<bsdf type="diffuse">\n')137 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.3"/>\n')138 fout.writelines('\t\t</bsdf> \n')139 fout.writelines('\t</shape>\n')140 141 fout.writelines('\t<shape type="cylinder">\n')142 fout.writelines('\t\t<float name="radius" value="0.16"/>\n')143 fout.writelines('\t\t<point name="p0" x="-0.1" y="$h2" z="0.64"/>\n')144 fout.writelines('\t\t<point name="p1" x="0.7" y="$h2" z="0.64"/>\n')145 fout.writelines('\t\t<bsdf type="diffuse">\n')146 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.3"/>\n')147 fout.writelines('\t\t</bsdf> \n')148 fout.writelines('\t</shape>\n')149 150 fout.writelines('\t<shape type="cylinder">\n')151 fout.writelines('\t\t<float name="radius" value="0.16"/>\n')152 fout.writelines('\t\t<point name="p0" x="-0.1" y="$h2" z="-0.64"/>\n')153 fout.writelines('\t\t<point name="p1" x="0.7" y="$h2" z="-0.64"/>\n')154 fout.writelines('\t\t<bsdf type="diffuse">\n')155 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.3"/>\n')156 fout.writelines('\t\t</bsdf> \n')157 fout.writelines('\t</shape>\n')158 fout.writelines('\t<shape type="disk">\n')159 fout.writelines('\t\t<transform name="toWorld">\n')160 fout.writelines('\t\t\t<rotate y="1" angle="-90"/>\n')161 fout.writelines('\t\t\t<scale value="0.16"/>\n')162 fout.writelines('\t\t\t<translate x="-0.1" y="$h1" z="0.0"/>\n')163 fout.writelines('\t\t</transform>\n')164 fout.writelines('\t\t<bsdf type="diffuse">\n')165 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.3"/>\n')166 fout.writelines('\t\t</bsdf>\n')167 fout.writelines('\t</shape>\n')168 fout.writelines('\t<shape type="disk">\n')169 fout.writelines('\t\t<transform name="toWorld">\n')170 fout.writelines('\t\t\t<rotate y="1" angle="-90"/>\n')171 fout.writelines('\t\t\t<scale value="0.16"/>\n')172 fout.writelines('\t\t\t<translate x="-0.1" y="$h2" z="0.64"/>\n')173 fout.writelines('\t\t</transform>\n')174 fout.writelines('\t\t<bsdf type="diffuse">\n')175 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.3"/>\n')176 fout.writelines('\t\t</bsdf>\n')177 fout.writelines('\t</shape>\n')178 179 fout.writelines('\t<shape type="disk">\n')180 fout.writelines('\t\t<transform name="toWorld">\n')181 fout.writelines('\t\t\t<rotate y="1" angle="-90"/>\n')182 fout.writelines('\t\t\t<scale value="0.16"/>\n')183 fout.writelines('\t\t\t<translate x="-0.1" y="$h2" z="-0.64"/>\n')184 fout.writelines('\t\t</transform>\n')185 fout.writelines('\t\t<bsdf type="diffuse">\n')186 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.3"/>\n')187 fout.writelines('\t\t</bsdf>\n')188 fout.writelines('\t</shape>\n')189 190 #########191 ### shape hair192 fout.writelines('\t<shape type="hair">\n')193 fout.writelines('\t\t<string name="filename" value="$fn"/>\n' )194 fout.writelines('\t\t<float name="radius" value="0.002"/> \n') 195 fout.writelines('\t\t<float name="angleThreshold" value="0.001"/>\n')196 197 if (isYarn4):198 #yarn4199 fout.writelines('\t\t<subsurface type="fibershader">\n')200 fout.writelines('\t\t\t<boolean name="useRandomInteractionPoint" value="true"/>\n')201 fout.writelines('\t\t\t<boolean name="sampleInteractionPointFromCircumference" value="false"/>\n')202 fout.writelines('\t\t\t<fiberscat type="simpfabric5">\n')203 fout.writelines('\t\t\t\t<float name="kD" value="0"/>\n')204 fout.writelines('\t\t\t\t<spectrum name="colorD" value="0.99,0.99,0.99"/>\n')205 fout.writelines('\t\t\t\t<spectrum name="colorR" value="0.25,0.25,0.3"/>\n')206 fout.writelines('\t\t\t\t<float name="betaR" value="1.23799781194"/>\n')207 fout.writelines('\t\t\t\t<float name="betaTT" value="9.99999999999"/>\n')208 fout.writelines('\t\t\t\t<float name="gammaTT" value="25.9890848941"/>\n')209 fout.writelines('\t\t\t\t<spectrum name="colorTT" value="0.45,0.86,0.95"/>\n')210 fout.writelines('\t\t\t\t<float name="alpha" value="5"/>\n')211 fout.writelines('\t\t\t</fiberscat>\n')212 fout.writelines('\t\t</subsurface> \n')213 elif (isYarn8):214 #yarn8215 fout.writelines('\t\t<subsurface type="fibershader">\n')216 fout.writelines('\t\t\t<boolean name="useRandomInteractionPoint" value="true"/>\n')217 fout.writelines('\t\t\t<boolean name="sampleInteractionPointFromCircumference" value="false"/>\n')218 fout.writelines('\t\t\t<fiberscat type="simpfabric5">\n')219 fout.writelines('\t\t\t\t<float name="kD" value="0"/>\n')220 fout.writelines('\t\t\t\t<spectrum name="colorD" value="0.99,0.99,0.99"/>\n')221 fout.writelines('\t\t\t\t<spectrum name="colorR" value="0.1,0.1,0.05"/>\n')222 fout.writelines('\t\t\t\t<float name="betaR" value="0.2"/>\n')223 fout.writelines('\t\t\t\t<float name="betaTT" value="27"/>\n')224 fout.writelines('\t\t\t\t<float name="gammaTT" value="38"/>\n')225 fout.writelines('\t\t\t\t<spectrum name="colorTT" value="0.93,0.53,0.01"/>\n')226 fout.writelines('\t\t\t\t<float name="alpha" value="5"/>\n')227 fout.writelines('\t\t\t</fiberscat>\n')228 fout.writelines('\t\t</subsurface> \n')229 elif (isYarn11):230 #yarn11231 fout.writelines('\t\t<subsurface type="fibershader">\n')232 fout.writelines('\t\t\t<boolean name="useRandomInteractionPoint" value="true"/>\n')233 fout.writelines('\t\t\t<boolean name="sampleInteractionPointFromCircumference" value="false"/>\n')234 fout.writelines('\t\t\t<fiberscat type="simpfabric5">\n')235 fout.writelines('\t\t\t\t<float name="kD" value="0"/>\n')236 fout.writelines('\t\t\t\t<spectrum name="colorD" value="0.99,0.99,0.99"/>\n')237 fout.writelines('\t\t\t\t<spectrum name="colorR" value="0.1,0.1,0.05"/>\n')238 fout.writelines('\t\t\t\t<float name="betaR" value="4.0"/>\n')239 fout.writelines('\t\t\t\t<float name="betaTT" value="10"/>\n')240 fout.writelines('\t\t\t\t<float name="gammaTT" value="20"/>\n')241 fout.writelines('\t\t\t\t<spectrum name="colorTT" value="0.88,0.83,0.01"/>\n')242 fout.writelines('\t\t\t\t<float name="alpha" value="5"/>\n')243 fout.writelines('\t\t\t</fiberscat>\n')244 fout.writelines('\t\t</subsurface> \n')245 elif (isYarn100):246 #yarn100247 fout.writelines('\t\t<subsurface type="fibershader">\n')248 fout.writelines('\t\t\t<boolean name="useRandomInteractionPoint" value="true"/>\n')249 fout.writelines('\t\t\t<boolean name="sampleInteractionPointFromCircumference" value="false"/>\n')250 fout.writelines('\t\t\t<fiberscat type="simpfabric5">\n')251 fout.writelines('\t\t\t\t<float name="kD" value="0"/>\n')252 fout.writelines('\t\t\t\t<spectrum name="colorD" value="0.99,0.99,0.99"/>\n')253 fout.writelines('\t\t\t\t<spectrum name="colorR" value="0.1,0.1,0.1"/>\n')254 fout.writelines('\t\t\t\t<float name="betaR" value="1.23799781194"/>\n')255 fout.writelines('\t\t\t\t<float name="betaTT" value="9.99999999999"/>\n')256 fout.writelines('\t\t\t\t<float name="gammaTT" value="25.9890848941"/>\n')257 fout.writelines('\t\t\t\t<spectrum name="colorTT" value="0.9,0.24,0.48"/>\n')258 fout.writelines('\t\t\t\t<float name="alpha" value="5"/>\n')259 fout.writelines('\t\t\t</fiberscat>\n')260 fout.writelines('\t\t</subsurface> \n') 261 else:262 # use bsdf263 fout.writelines('\t\t<bsdf type="roughplastic">\n')264 fout.writelines('\t\t\t<spectrum name="diffuseReflectance" value="0.8, 0.1, 0.1"/>\n')265 fout.writelines('\t\t\t<float name="alpha" value="0.05"/>\n')266 fout.writelines('\t\t</bsdf> \n')267 268 fout.writelines('\t</shape>\n')269 fout.writelines('\n')270 271 #### rectangle272# fout.writelines('\t<shape type="rectangle">\n')273# fout.writelines('\t\t<transform name="toWorld">\n')274# fout.writelines('\t\t\t<rotate y="1" angle="-90"/>\n')275# fout.writelines('\t\t\t<scale x="5" y="5" z="5"/>\n')276# fout.writelines('\t\t\t<translate x="3"/>\n')277# fout.writelines('\t\t</transform>\n')278# fout.writelines('\t\t<bsdf type="diffuse">\n')279# fout.writelines('\t\t\t<texture type="bitmap" name="reflectance">\n')280# fout.writelines('\t\t\t\t<string name="filename" value="concrete.jpg"/>\n')281# fout.writelines('\t\t\t</texture>\n')282# fout.writelines('\t\t</bsdf>\n')283# fout.writelines('\t\t<bsdf type="diffuse">\n')284# fout.writelines('\t\t\t<spectrum name="diffuseReflectance" value="0.5, 0.5, 0.5"/>\n')285# fout.writelines('\t\t</bsdf>\n')286# fout.writelines('\t</shape>\n')287 288 fout.writelines('\t<emitter type="constant"> \n')289 fout.writelines('\t\t<spectrum name="radiance" value="0.01"/> \n')290 fout.writelines('\t</emitter> \n')291 292 #### light293 fout.writelines('\t<shape type="rectangle"> \n')294 fout.writelines('\t\t<transform name="toWorld"> \n')295 fout.writelines('\t\t\t<rotate y="1" angle="90"/> \n')296 fout.writelines('\t\t\t<rotate x="1" angle="45"/> \n')297 fout.writelines('\t\t\t<scale x="25" y="25" z="25"/> \n')298 fout.writelines('\t\t\t<translate x="-20" y="60" z="0.0"/> \n')299 fout.writelines('\t\t</transform> \n')300 fout.writelines('\t\t<emitter type="area"> \n')301 fout.writelines('\t\t\t<spectrum name="radiance" value="25"/> \n')302 fout.writelines('\t\t</emitter> \n')303 fout.writelines('\t</shape> \n')304 305 306 ### sensor307 fout.writelines('\t<sensor type="perspective">\n')308 fout.writelines('\t\t<string name="fovAxis" value="smaller"/>\n')309 fout.writelines('\t\t<transform name="toWorld">\n')310 fout.writelines('\t\t\t<lookAt origin="-10 0 0" target="0 0 0" up="0 1 0"/> \n')311 fout.writelines('\t\t</transform>\n')312 fout.writelines('\t\t<float name="fov" value="3.0"/>\n')313 fout.writelines('\t\t<sampler type="ldsampler">\n')314 fout.writelines('\t\t\t<integer name="sampleCount" value="%d"/>\n' %spp)315 fout.writelines('\t\t</sampler>\n')316 fout.writelines('\t\t<film id="film" type="hdrfilm">\n')317 fout.writelines('\t\t\t<integer name="width" value="1024"/>\n') 318 fout.writelines('\t\t\t<integer name="height" value="256"/>\n')319 fout.writelines('\t\t\t<rfilter type="gaussian"/>\n')320 fout.writelines('\t\t\t<boolean name="banner" value="false" />\n')321 fout.writelines('\t\t</film>\n')322 fout.writelines('\t</sensor>\n')323 fout.writelines('\n')324 325 fout.writelines('</scene>')326 ...

Full Screen

Full Screen

generate_tiled.py

Source:generate_tiled.py Github

copy

Full Screen

...23 sz = 22 #flat tiling (for teeth cases)24 else: 25 sz = 33 #cylinder (for stretch case)26 27 fout.writelines('<scene version="0.4.4"> \n') 28 fout.writelines('\t<integrator type="path"> \n')29 fout.writelines('\t\t<integer name="maxDepth" value="25"/> \n')30 fout.writelines('\t\t<integer name="rrDepth" value="30"/> \n')31 fout.writelines('\t</integrator> \n')32 fout.writelines('\n') 33 if (isYarn8):34 #### cylinders 1.2 0011035 fout.writelines('\t<shape type="cylinder">\n')36 fout.writelines('\t\t<float name="radius" value="0.16"/>\n')37 fout.writelines('\t\t<point name="p0" x="-1.8" y="$h2" z="0"/>\n')38 fout.writelines('\t\t<point name="p1" x="1.8" y="$h2" z="0"/>\n')39 fout.writelines('\t\t<bsdf type="diffuse">\n')40 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.1"/>\n')41 fout.writelines('\t\t</bsdf> \n')42 fout.writelines('\t</shape>\n')43 fout.writelines('\t<shape type="cylinder">\n')44 fout.writelines('\t\t<float name="radius" value="0.16"/>\n')45 fout.writelines('\t\t<point name="p0" x="-1.8" y="$h2" z="0.48"/>\n')46 fout.writelines('\t\t<point name="p1" x="1.8" y="$h2" z="0.48"/>\n')47 fout.writelines('\t\t<bsdf type="diffuse">\n')48 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.1"/>\n')49 fout.writelines('\t\t</bsdf> \n')50 fout.writelines('\t</shape>\n')51 fout.writelines('\t<shape type="cylinder">\n')52 fout.writelines('\t\t<float name="radius" value="0.16"/>\n')53 fout.writelines('\t\t<point name="p0" x="-1.8" y="$h2" z="-0.48"/>\n')54 fout.writelines('\t\t<point name="p1" x="1.8" y="$h2" z="-0.48"/>\n')55 fout.writelines('\t\t<bsdf type="diffuse">\n')56 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.1"/>\n')57 fout.writelines('\t\t</bsdf> \n')58 fout.writelines('\t</shape>\n')59 fout.writelines('\t<shape type="cylinder">\n')60 fout.writelines('\t\t<float name="radius" value="0.16"/>\n')61 fout.writelines('\t\t<point name="p0" x="-1.8" y="$h1" z="0.96"/>\n')62 fout.writelines('\t\t<point name="p1" x="1.8" y="$h1" z="0.96"/>\n')63 fout.writelines('\t\t<bsdf type="diffuse">\n')64 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.1"/>\n')65 fout.writelines('\t\t</bsdf> \n')66 fout.writelines('\t</shape>\n')67 fout.writelines('\t<shape type="cylinder">\n')68 fout.writelines('\t\t<float name="radius" value="0.16"/>\n')69 fout.writelines('\t\t<point name="p0" x="-1.8" y="$h1" z="-0.96"/>\n')70 fout.writelines('\t\t<point name="p1" x="1.8" y="$h1" z="-0.96"/>\n')71 fout.writelines('\t\t<bsdf type="diffuse">\n')72 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.1"/>\n')73 fout.writelines('\t\t</bsdf> \n')74 fout.writelines('\t</shape>\n')75 76 if (isYarn11): 77 ######## cylinder 1.678 fout.writelines('\t<shape type="cylinder">\n')79 fout.writelines('\t\t<float name="radius" value="0.16"/>\n')80 fout.writelines('\t\t<point name="p0" x="-1.8" y="$h1" z="0"/>\n')81 fout.writelines('\t\t<point name="p1" x="1.8" y="$h1" z="0"/>\n')82 fout.writelines('\t\t<bsdf type="diffuse">\n')83 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.1"/>\n')84 fout.writelines('\t\t</bsdf> \n')85 fout.writelines('\t</shape>\n')86 87 fout.writelines('\t<shape type="cylinder">\n')88 fout.writelines('\t\t<float name="radius" value="0.16"/>\n')89 fout.writelines('\t\t<point name="p0" x="-1.8" y="$h2" z="0.64"/>\n')90 fout.writelines('\t\t<point name="p1" x="1.8" y="$h2" z="0.64"/>\n')91 fout.writelines('\t\t<bsdf type="diffuse">\n')92 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.1"/>\n')93 fout.writelines('\t\t</bsdf> \n')94 fout.writelines('\t</shape>\n')95 96 fout.writelines('\t<shape type="cylinder">\n')97 fout.writelines('\t\t<float name="radius" value="0.16"/>\n')98 fout.writelines('\t\t<point name="p0" x="-1.8" y="$h2" z="-0.64"/>\n')99 fout.writelines('\t\t<point name="p1" x="1.8" y="$h2" z="-0.64"/>\n')100 fout.writelines('\t\t<bsdf type="diffuse">\n')101 fout.writelines('\t\t\t<spectrum name="reflectance" value="0.1"/>\n')102 fout.writelines('\t\t</bsdf> \n')103 fout.writelines('\t</shape>\n')104 ### shape hair105 fout.writelines('\t<shape type="shapegroup" id="myShapeGroup">\n')106 fout.writelines('\t\t<shape type="hair">\n')107 fout.writelines('\t\t\t<string name="filename" value="$fn"/>\n' )108 fout.writelines('\t\t\t<float name="radius" value="0.002"/> \n') 109 fout.writelines('\t\t\t<float name="angleThreshold" value="0.001"/>\n')110 111 if (isYarn4):112 #yarn4113 fout.writelines('\t\t<subsurface type="fibershader">\n')114 fout.writelines('\t\t\t<boolean name="useRandomInteractionPoint" value="true"/>\n')115 fout.writelines('\t\t\t<boolean name="sampleInteractionPointFromCircumference" value="false"/>\n')116 fout.writelines('\t\t\t<fiberscat type="simpfabric5">\n')117 fout.writelines('\t\t\t\t<float name="kD" value="0"/>\n')118 fout.writelines('\t\t\t\t<spectrum name="colorD" value="0.99,0.99,0.99"/>\n')119 fout.writelines('\t\t\t\t<spectrum name="colorR" value="0.25,0.25,0.3"/>\n')120 fout.writelines('\t\t\t\t<float name="betaR" value="1.23799781194"/>\n')121 fout.writelines('\t\t\t\t<float name="betaTT" value="9.99999999999"/>\n')122 fout.writelines('\t\t\t\t<float name="gammaTT" value="25.9890848941"/>\n')123 fout.writelines('\t\t\t\t<spectrum name="colorTT" value="0.45,0.86,0.95"/>\n')124 fout.writelines('\t\t\t\t<float name="alpha" value="5"/>\n')125 fout.writelines('\t\t\t</fiberscat>\n')126 fout.writelines('\t\t</subsurface> \n')127 elif (isYarn8):128 #yarn8129 fout.writelines('\t\t<subsurface type="fibershader">\n')130 fout.writelines('\t\t\t<boolean name="useRandomInteractionPoint" value="true"/>\n')131 fout.writelines('\t\t\t<boolean name="sampleInteractionPointFromCircumference" value="false"/>\n')132 fout.writelines('\t\t\t<fiberscat type="simpfabric5">\n')133 fout.writelines('\t\t\t\t<float name="kD" value="0"/>\n')134 fout.writelines('\t\t\t\t<spectrum name="colorD" value="0.99,0.99,0.99"/>\n')135 fout.writelines('\t\t\t\t<spectrum name="colorR" value="0.1,0.1,0.05"/>\n')136 fout.writelines('\t\t\t\t<float name="betaR" value="0.2"/>\n')137 fout.writelines('\t\t\t\t<float name="betaTT" value="27"/>\n')138 fout.writelines('\t\t\t\t<float name="gammaTT" value="38"/>\n')139 fout.writelines('\t\t\t\t<spectrum name="colorTT" value="0.93,0.53,0.01"/>\n')140 fout.writelines('\t\t\t\t<float name="alpha" value="5"/>\n')141 fout.writelines('\t\t\t</fiberscat>\n')142 fout.writelines('\t\t</subsurface> \n')143 elif (isYarn11):144 #yarn11145 fout.writelines('\t\t<subsurface type="fibershader">\n')146 fout.writelines('\t\t\t<boolean name="useRandomInteractionPoint" value="true"/>\n')147 fout.writelines('\t\t\t<boolean name="sampleInteractionPointFromCircumference" value="false"/>\n')148 fout.writelines('\t\t\t<fiberscat type="simpfabric5">\n')149 fout.writelines('\t\t\t\t<float name="kD" value="0"/>\n')150 fout.writelines('\t\t\t\t<spectrum name="colorD" value="0.99,0.99,0.99"/>\n')151 fout.writelines('\t\t\t\t<spectrum name="colorR" value="0.1,0.1,0.05"/>\n')152 fout.writelines('\t\t\t\t<float name="betaR" value="4.0"/>\n')153 fout.writelines('\t\t\t\t<float name="betaTT" value="10"/>\n')154 fout.writelines('\t\t\t\t<float name="gammaTT" value="20"/>\n')155 fout.writelines('\t\t\t\t<spectrum name="colorTT" value="0.88,0.83,0.01"/>\n')156 fout.writelines('\t\t\t\t<float name="alpha" value="5"/>\n')157 fout.writelines('\t\t\t</fiberscat>\n')158 fout.writelines('\t\t</subsurface> \n')159 elif (isYarn100):160 #yarn100161 fout.writelines('\t\t<subsurface type="fibershader">\n')162 fout.writelines('\t\t\t<boolean name="useRandomInteractionPoint" value="true"/>\n')163 fout.writelines('\t\t\t<boolean name="sampleInteractionPointFromCircumference" value="false"/>\n')164 fout.writelines('\t\t\t<fiberscat type="simpfabric5">\n')165 fout.writelines('\t\t\t\t<float name="kD" value="0"/>\n')166 fout.writelines('\t\t\t\t<spectrum name="colorD" value="0.99,0.99,0.99"/>\n')167 fout.writelines('\t\t\t\t<spectrum name="colorR" value="0.1,0.1,0.1"/>\n')168 fout.writelines('\t\t\t\t<float name="betaR" value="1.23799781194"/>\n')169 fout.writelines('\t\t\t\t<float name="betaTT" value="9.99999999999"/>\n')170 fout.writelines('\t\t\t\t<float name="gammaTT" value="25.9890848941"/>\n')171 fout.writelines('\t\t\t\t<spectrum name="colorTT" value="0.9,0.24,0.48"/>\n')172 fout.writelines('\t\t\t\t<float name="alpha" value="5"/>\n')173 fout.writelines('\t\t\t</fiberscat>\n')174 fout.writelines('\t\t</subsurface> \n') 175 else:176 # use bsdf177 fout.writelines('\t\t<bsdf type="roughplastic">\n')178 fout.writelines('\t\t\t<spectrum name="diffuseReflectance" value="0.8, 0.1, 0.1"/>\n')179 fout.writelines('\t\t\t<float name="alpha" value="0.05"/>\n')180 fout.writelines('\t\t</bsdf> \n')181 182 183 184 fout.writelines('\t\t</shape>\n')185 fout.writelines('\t</shape>\n')186 fout.writelines('\n')187 188 #use cylinder tiling 189 for i in range (0,sz):190 ### shape hair191 fout.writelines('\t<shape type="instance">\n')192 fout.writelines('\t\t<ref id="myShapeGroup"/>\n' ) 193 fout.writelines('\t\t<transform name="toWorld">\n') 194 195# x_t = 0.11 * float(i) #cylinder tiling for synthesized result196 197 x_t = 0.06 * float(i)198 y_t = 1.0 - x_t * x_t/1.8199 if (isFlat):200 fout.writelines('\t\t\t<translate x="%.6f" />\n' % (1.2*x_t))#flat tiling 201 else:202 fout.writelines('\t\t\t<translate x="%.6f" y="%.6f" />\n' % (x_t, y_t) )#cylinder tiling203 fout.writelines('\t\t</transform> \n')204 fout.writelines('\t</shape>\n')205 fout.writelines('\n')206 207 for i in range (1,sz):208 ### shape hair209 fout.writelines('\t<shape type="instance">\n')210 fout.writelines('\t\t<ref id="myShapeGroup"/>\n' ) 211 fout.writelines('\t\t<transform name="toWorld">\n') 212 213# x_t = -1.0 * 0.11 * float(i) #cylinder tiling for synthesized result214 215 x_t = -1.0 * 0.06 * float(i)216 y_t = 1.0 - x_t * x_t/1.8217 if (isFlat):218 fout.writelines('\t\t\t<translate x="%.6f" />\n' % (1.2*x_t))#flat tiling219 else:220 fout.writelines('\t\t\t<translate x="%.6f" y="%.6f" />\n' % (x_t, y_t) )#cylinder tiling 221 fout.writelines('\t\t</transform> \n')222 fout.writelines('\t</shape>\n')223 fout.writelines('\n')224 225 #### rectangle226 fout.writelines('\t<shape type="rectangle">\n')227 fout.writelines('\t\t<transform name="toWorld">\n')228 fout.writelines('\t\t\t<rotate x="1" angle="-90"/>\n')229 fout.writelines('\t\t\t<translate y="-0.1"/>\n')230 fout.writelines('\t\t\t<scale x="6" y="6" z="6"/>\n')231 fout.writelines('\t\t</transform>\n')232 fout.writelines('\t\t<bsdf type="diffuse">\n')233 fout.writelines('\t\t\t<texture type="bitmap" name="reflectance">\n')234 fout.writelines('\t\t\t\t<string name="filename" value="concrete.jpg"/>\n')235 fout.writelines('\t\t\t</texture>\n')236 fout.writelines('\t\t</bsdf>\n')237 fout.writelines('\t</shape>\n')238 239 #### light240 fout.writelines('\t<emitter type="constant">\n')241 fout.writelines('\t\t<spectrum name="radiance" value="0.3"/> \n')242 fout.writelines('\t</emitter>\n')243 244 #### light245 # fout.writelines('\t<shape type="sphere">\n')246 # fout.writelines('\t\t<point name="center" x="-5.0" y="80.0" z="0.0"/>\n')247 # fout.writelines('\t\t<float name="radius" value="10.0"/>\n')248 # fout.writelines('\t\t<emitter type="area">\n')249 # fout.writelines('\t\t\t<spectrum name="radiance" value="40"/> \n')250 # fout.writelines('\t\t</emitter>\n')251 # fout.writelines('\t</shape>\n')252 # fout.writelines('\n')253 254 #### light255 fout.writelines('\t<shape type="rectangle"> \n')256 fout.writelines('\t\t<transform name="toWorld"> \n')257 fout.writelines('\t\t\t<rotate x="1" angle="90"/> \n')258 fout.writelines('\t\t\t<scale x="1" y="40" z="20"/> \n')259 fout.writelines('\t\t\t<translate x="0.0" y="100.0" z="0.0"/> \n')260 fout.writelines('\t\t</transform> \n')261 fout.writelines('\t\t<emitter type="area"> \n')262 fout.writelines('\t\t\t<spectrum name="radiance" value="50"/> \n')263 fout.writelines('\t\t</emitter> \n')264 fout.writelines('\t</shape> \n')265 266 267 # ### sensor268 fout.writelines('\t<sensor type="perspective">\n')269 fout.writelines('\t\t<string name="fovAxis" value="smaller"/>\n')270 271 fout.writelines('\t\t<transform name="toWorld">\n')272 # fout.writelines('\t\t\t<lookAt origin="-17 40 15" target="0 0.9 1.1" up="0 1 0"/> \n') #9:16 ratio for video273 # fout.writelines('\t\t\t<lookAt origin="-17 40 15" target="0 -0.3 -0.0" up="0 1 0"/> \n') #cylinder tiling for snthesized result274 if (isFlat):275 fout.writelines('\t\t\t<lookAt origin="-17 30 5" target="0 0 0" up="0 1 0"/> \n') #flat tiling for video276 else:277 fout.writelines('\t\t\t<lookAt origin="-17 40 15" target="0 -0.9 -0.4" up="0 1 0"/> \n') #cylinder tiling278 fout.writelines('\t\t</transform>\n')279 280 # fout.writelines('\t\t<float name="fov" value="7.1"/>\n')#cylinder tiling for snthesized result281 fout.writelines('\t\t<float name="fov" value="6.3"/>\n')282 fout.writelines('\t\t<sampler type="ldsampler">\n')283 fout.writelines('\t\t\t<integer name="sampleCount" value="%d"/>\n' %spp) #256284 fout.writelines('\t\t</sampler>\n')285 fout.writelines('\t\t<film id="film" type="hdrfilm">\n')286 fout.writelines('\t\t\t<integer name="width" value="1024"/>\n') # for video287 fout.writelines('\t\t\t<integer name="height" value="576"/>\n')288 fout.writelines('\t\t\t<rfilter type="gaussian"/>\n')289 fout.writelines('\t\t\t<boolean name="banner" value="false" />\n')290 fout.writelines('\t\t</film>\n')291 fout.writelines('\t</sensor>\n')292 fout.writelines('\n')293 294 fout.writelines('</scene>')295 ...

Full Screen

Full Screen

init_setting.py

Source:init_setting.py Github

copy

Full Screen

...7 application_configuration.read("/etc/ryoki_config.ini")8 with open("./configuration.py", "w") as config_file:9 # Writing data to a file10 # System11 config_file.writelines("REBOOT_TRACKFILE = " + \12 str(application_configuration["system"]["REBOOT_TRACKFILE"]) + "\n")13 config_file.writelines("REBOOT_SHORT_DELAY = " + \14 str(application_configuration["system"]["REBOOT_SHORT_DELAY"]) + "\n")15 config_file.writelines("REBOOT_LONG_DELAY = " + \16 str(application_configuration["system"]["REBOOT_LONG_DELAY"]) + "\n")17 config_file.writelines("KEEPING_OUTPUT_TIME = " + \18 str(application_configuration["system"]["KEEPING_OUTPUT_TIME"]) + "\n")19 # Cloud configuration20 config_file.writelines("CERT_PATH = " + \21 str(application_configuration["cloud_configuration"]["CERT_PATH"]) + "\n")22 config_file.writelines("CERTIFICATE_NAME = " + \23 str(application_configuration["cloud_configuration"]["CERTIFICATE_NAME"]) + "\n")24 config_file.writelines("ROOTCA_NAME = " + \25 str(application_configuration["cloud_configuration"]["ROOTCA_NAME"]) + "\n")26 config_file.writelines("PRIVATE_KEY_NAME = " + \27 str(application_configuration["cloud_configuration"]["PRIVATE_KEY_NAME"]) + "\n")28 config_file.writelines("AWS_ENDPOINT = " + \29 str(application_configuration["cloud_configuration"]["AWS_ENDPOINT"]) + "\n")30 config_file.writelines("AWS_TOPIC_PREFIX = " + \31 str(application_configuration["cloud_configuration"]["AWS_TOPIC_PREFIX"]) + "\n")32 config_file.writelines("AWS_DEVICES_SUBSCRIBE_TOPIC_STAGE = " + \33 str(application_configuration["cloud_configuration"]["AWS_DEVICES_SUBSCRIBE_TOPIC_STAGE"]) + "\n")34 config_file.writelines("AWS_CONTROL_SUBSCRIBE_TOPIC_STAGE = " + \35 str(application_configuration["cloud_configuration"]["AWS_CONTROL_SUBSCRIBE_TOPIC_STAGE"]) + "\n")36 config_file.writelines("AWS_TRACKING_SUBSCRIBE_TOPIC_STAGE = " + \37 str(application_configuration["cloud_configuration"]["AWS_TRACKING_SUBSCRIBE_TOPIC_STAGE"]) + "\n")38 config_file.writelines("AWS_REQ_DEV_PUBLISH_TOPIC_STAGE = " + \39 str(application_configuration["cloud_configuration"]["AWS_REQ_DEV_PUBLISH_TOPIC_STAGE"]) + "\n")40 config_file.writelines("AWS_CTL_RESULT_PUBLISH_TOPIC_STAGE = " + \41 str(application_configuration["cloud_configuration"]["AWS_CTL_RESULT_PUBLISH_TOPIC_STAGE"]) + "\n")42 config_file.writelines("AWS_STATUS_PUBLISH_TOPIC_STAGE = " + \43 str(application_configuration["cloud_configuration"]["AWS_STATUS_PUBLISH_TOPIC_STAGE"]) + "\n")44 config_file.writelines("STATUS_PUBLISH_PERIOD = " + \45 str(application_configuration["cloud_configuration"]["STATUS_PUBLISH_PERIOD"]) + "\n")46 config_file.writelines("AWS_DATA_PUBLISH_TOPIC_STAGE = " + \47 str(application_configuration["cloud_configuration"]["AWS_DATA_PUBLISH_TOPIC_STAGE"]) + "\n")48 config_file.writelines("DATA_PUBLISH_PERIOD = " + \49 str(application_configuration["cloud_configuration"]["DATA_PUBLISH_PERIOD"]) + "\n")50 config_file.writelines("SLEEP_TIME_OF_RETRYING_CONNECT = " + \51 str(application_configuration["cloud_configuration"]["SLEEP_TIME_OF_RETRYING_CONNECT"]) + "\n")52 config_file.writelines("SLEEP_TIME_OF_RETRYING_TO_GET_DEVICES = " + \53 str(application_configuration["cloud_configuration"]["SLEEP_TIME_OF_RETRYING_TO_GET_DEVICES"]) + "\n")54 config_file.writelines("NUMBER_OF_RETRY_CONNECTIONS = " + \55 str(application_configuration["cloud_configuration"]["NUMBER_OF_RETRY_CONNECTIONS"]) + "\n")56 config_file.writelines("NUMBER_OF_RETRY_SUBCRIBING = " + \57 str(application_configuration["cloud_configuration"]["NUMBER_OF_RETRY_SUBCRIBING"]) + "\n")58 config_file.writelines("NUMBER_OF_RETRY_PUBLISHING = " + \59 str(application_configuration["cloud_configuration"]["NUMBER_OF_RETRY_PUBLISHING"]) + "\n")60 config_file.writelines("SLEEP_TIME_OF_PUBLISH_CLOUD_DATA = " + \61 str(application_configuration["cloud_configuration"]["SLEEP_TIME_OF_PUBLISH_CLOUD_DATA"]) + "\n")62 config_file.writelines("TRACKING_FILE = " + \63 str(application_configuration["cloud_configuration"]["TRACKING_FILE"]) + "\n")64 config_file.writelines("REQUIRED_CTL_REQ_NO = " + \65 str(application_configuration["cloud_configuration"]["REQUIRED_CTL_REQ_NO"]) + "\n")66 config_file.writelines("REQUIRED_MLD_REQ_NO = " + \67 str(application_configuration["cloud_configuration"]["REQUIRED_MLD_REQ_NO"]) + "\n")68 config_file.writelines("SLEEP_TIME_5M = " + \69 str(application_configuration["cloud_configuration"]["SLEEP_TIME_5M"]) + "\n")70 # Database71 config_file.writelines("DATABASE_NAME = " + \72 str(application_configuration["database"]["DATABASE_NAME"]) + "\n")73 # Logging74 config_file.writelines("LOG_FILE_NAME = " + \75 str(application_configuration["logging"]["LOG_FILE_NAME"]) + "\n")76 # EnOcean77 config_file.writelines("ENO_TTYPATH = " + \78 str(application_configuration["enocean"]["ENO_TTYPATH"]) + "\n")79 config_file.writelines("ENOCEAN_READING_SLEEP_TIME = " + \80 str(application_configuration["enocean"]["ENOCEAN_READING_SLEEP_TIME"]) + "\n")81 config_file.writelines("ENOCEAN_STATUS_TIMEOUT = " + \82 str(application_configuration["enocean"]["ENOCEAN_STATUS_TIMEOUT"]) + "\n")83 config_file.writelines("CO2_928_TIMEOUT = " + \84 str(application_configuration["enocean"]["CO2_928_TIMEOUT"]) + "\n")85 config_file.writelines("ENOCEAN_KEEPING_OUTPUT_TIME = " + \86 str(application_configuration["enocean"]["ENOCEAN_KEEPING_OUTPUT_TIME"]) + "\n")87 # Modbus88 config_file.writelines("MODBUS_TTYPATH = " + \89 str(application_configuration["modbus"]["MODBUS_TTYPATH"]) + "\n")90 config_file.writelines("MODBUS_READING_SLEEP_TIME = " + \91 str(application_configuration["modbus"]["MODBUS_READING_SLEEP_TIME"]) + "\n")92 config_file.writelines("MODBUS_STATUS_TIMEOUT = " + \93 str(application_configuration["modbus"]["MODBUS_STATUS_TIMEOUT"]) + "\n")94 config_file.writelines("MODBUS_KEEPING_OUTPUT_TIME = " + \95 str(application_configuration["modbus"]["MODBUS_KEEPING_OUTPUT_TIME"]) + "\n")96 # FTP97 config_file.writelines("FTP_SERVER_FOLDER_PATH = " + \98 str(application_configuration["ftp"]["FTP_SERVER_FOLDER_PATH"]) + "\n") ...

Full Screen

Full Screen

proto2csharp.py

Source:proto2csharp.py Github

copy

Full Screen

...30 msgname = ""31 comment = ""32 33def ParseMsgIDDefine(fs,msgidList):34 fs.writelines("using System;");35 fs.writelines("using System.Collections.Generic;");36 fs.writelines("using System.Text;");37 fs.writelines("public class MsgIDDefine");38 fs.writelines("{");39 fs.writelines("\tstatic Dictionary<int, string> msgid2msgname = new Dictionary<int, string>();");40 fs.writelines("\tstatic Dictionary<string, int> msgname2msgid = new Dictionary<string, int>();");41 fs.writelines("\tstatic void Initialize()");42 fs.writelines("\t{");4344 for _msgDef in msgidList:45 fs.writelines("\t\tmsgid2msgname[%s] = \"%s\";" % (_msgDef.msgid, _msgDef.msgname));46 fs.writelines("\t\tmsgname2msgid[\"%s\"] = %s;" % (_msgDef.msgname, _msgDef.msgid));47 fs.writelines("\t}");48 fs.writelines("\tstatic string GetMsgNameByID(int msgid)");49 fs.writelines("\t{");50 fs.writelines("\t\tstring msgname = null;");51 fs.writelines("\t\tif (msgid2msgname.TryGetValue(msgid,out msgname))");52 fs.writelines("\t\t{");53 fs.writelines("\t\t\treturn msgname;");54 fs.writelines("\t\t}");55 fs.writelines("\t\treturn \"\";");56 fs.writelines("\t}");5758 fs.writelines("\tstatic int GetMsgIDByName(string msgname)");59 fs.writelines("\t{");60 fs.writelines("\t\tint msgid = 0;");61 fs.writelines("\t\tif (msgname2msgid.TryGetValue(msgname,out msgid))");62 fs.writelines("\t\t{");63 fs.writelines("\t\t\treturn msgid;");64 fs.writelines("\t\t}");65 fs.writelines("\t\treturn 0;");66 fs.writelines("\t}");67 fs.writelines("}");68 fs.flush();6970 fs.close();71 72def ParseMsgIDDef(fs,msgidList):73 fs.writelines("using System;");74 fs.writelines("using System.Collections.Generic;");75 fs.writelines("using System.Text;");76 fs.writelines("public class MsgIDDef");77 fs.writelines("{");7879 fs.writelines("\tprivate Dictionary<int, Type> sc_msg_dic = new Dictionary<int, Type>();");80 fs.writelines("\tprivate static MsgIDDef instance;");81 fs.writelines("\tpublic static MsgIDDef Instance()");8283 fs.writelines("\t{");8485 fs.writelines("\t\tif (null == instance)");86 fs.writelines("\t\t{");87 fs.writelines("\t\t\tinstance = new MsgIDDef();");88 fs.writelines("\t\t}");89 fs.writelines("\t\treturn instance;");90 fs.writelines("\t}");919293 fs.writelines("\tprivate MsgIDDef()");94 fs.writelines("\t{");95 for _msgDef in msgidList:96 tmpMsgName = _msgDef.msgname;97 fs.writelines("\t\tsc_msg_dic.Add(%s,typeof(%s));"% (_msgDef.msgid, tmpMsgName));9899 fs.writelines("\t}");100 fs.writelines("\tpublic Type GetMsgType(int msgID)");101 fs.writelines("\t{");102 fs.writelines("\t\tType msgType = null;");103 fs.writelines("\t\tsc_msg_dic.TryGetValue(msgID, out msgType);");104 fs.writelines("\t\tif (msgType==null)");105 fs.writelines("\t\t{");106 fs.writelines("\t\t\treturn null;");107 fs.writelines("\t\t}");108 fs.writelines("\t\treturn msgType;");109 fs.writelines("\t}");110 fs.writelines("}");111112 fs.flush();113 fs.close();114115def ParseMsgIDDefineDic(fs,msgidList):116 fs.writelines("using System;");117 fs.writelines("using System.Collections.Generic;");118 fs.writelines("using System.Text;");119 fs.writelines("public class MsgIDDefineDic");120 fs.writelines("{");121122 for _msgDef in msgidList:123 fs.writelines("\tpublic const int %s = %s; %s"%( _msgDef.msgname.upper().replace(".","_"), _msgDef.msgid,_msgDef.comment));124125 fs.writelines("}");126 fs.flush();127 fs.close();128129def parse_msgfile(msgid_conf):130 msg_info_list = []131 msg_file = open(msgid_conf,"r")132 for line in msg_file.readlines():133 line = line.strip().rstrip()134135 if not len(line) or line.startswith("#"):136 continue137 array_info = line.split("=")138 msgid = array_info[0].strip().rstrip() #MSGID139 140 array_info = array_info[1].split(',') #MSGNAME141 msgname = array_info[0].strip().rstrip()142 143 array_info = array_info[1].split("#") 144 comment = ""145 if len(array_info) > 1:146 comment = "//" + array_info[1].strip().rstrip()147 msg_info_list.append(MsgInfo(msgid,msgname,comment))148 149 return msg_info_list150 151class WrapFile:152 fs = None153 def __init__(self,real_file):154 self.fs = real_file155 def writelines(self,s):156 self.fs.write(s + "\n")157 def flush(self):158 self.fs.flush()159 def close(self):160 self.fs.close()161 162l=parse_msgfile(msgid_conf)163164targetMsgIDPath = "../Assets/Scripts/socket/MessageDef/MsgIDDefineDic.cs";165targetCSPath = "../Assets/Scripts/socket/MessageDef/MsgIDDefine.cs";166targetCSPath2 = "../Assets/Scripts/socket/MessageDef/MsgIDDef.cs";167168f = WrapFile(open(targetCSPath,"w+"))169ParseMsgIDDefine(f,l) ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run green automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful