@@ -53,12 +53,6 @@ def classToFileName(cl):
5353 """
5454 return cl .replace ("/" ,"Division" ).replace ("*" ,"Multiplication" )
5555
56- # Bitmap
57- # extends GraphicItem
58- # extent
59- # fileName
60- # imageSource
61-
6256exp_float = '[+-]?\d+(?:.\d+)?(?:e[+-]?\d+)?'
6357
6458element_id = 0
@@ -296,7 +290,11 @@ def getGraphicsForClass(modelicaClass):
296290 graphicsObj ['href' ] = "data:image;base64," + g [9 ].strip ('"' )
297291 else :
298292 fname = ask_omc ('uriToFilename' , g [8 ], parsed = False ).strip ().strip ('"' )
299- fdata = open (fname , "rb" ).read ()
293+ if os .path .exists (fname ):
294+ fdata = open (fname , "rb" ).read ()
295+ else :
296+ fname = os .path .join (baseDir , g [8 ].strip ('"' ))
297+ fdata = open (fname , "rb" ).read ()
300298 graphicsObj ['href' ] = "data:image;base64," + base64 .b64encode (fdata )
301299
302300 if not 'type' in graphicsObj :
@@ -1141,11 +1139,14 @@ def generateSvg(filename, iconGraphics, includeInvisibleText, warn_duplicates):
11411139
11421140 dwg .add (group )
11431141 hashName = hashlib .sha1 (dwg .tostring ().encode ("utf-8" )).hexdigest () + ".svg"
1144- hashPath = os .path .join (os .path .dirname (filename ),hashName )
1142+ hashPath = os .path .join (os .path .dirname (filename ),hashName [: 1 ], hashName )
11451143 if not os .path .exists (hashPath ):
11461144 dwg .saveas (hashPath )
11471145 if not os .path .exists (filename ):
1148- os .symlink (hashName , filename )
1146+ try :
1147+ os .symlink (hashName , filename )
1148+ except OSError as e :
1149+ logger .error (filename + " already exists" )
11491150 else :
11501151 if warn_duplicates :
11511152 logger .warning ('Target file {0} already exists' .format (filename ))
@@ -1185,6 +1186,7 @@ def getBaseClasses(modelica_class, base_classes):
11851186
11861187
11871188def main ():
1189+ global baseDir
11881190 t = time .time ()
11891191 parser = OptionParser ()
11901192 parser .add_option ("--with-html" , help = "Generate an HTML report with all SVG-files" , action = "store_true" , dest = "with_html" , default = False )
@@ -1232,8 +1234,10 @@ def main():
12321234 logger .info ('Application started' )
12331235 logger .info ('Output directory: ' + output_dir )
12341236
1235- if not os .path .exists (output_dir ):
1236- os .makedirs (output_dir )
1237+ for f in ['0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , 'a' , 'b' , 'c' , 'd' , 'e' , 'f' ]:
1238+ output_dirx = os .path .join (output_dir , f )
1239+ if not os .path .exists (output_dirx ):
1240+ os .makedirs (output_dirx )
12371241
12381242 success = True
12391243
@@ -1265,6 +1269,8 @@ def main():
12651269 fh .setFormatter (formatter )
12661270 logger .addHandler (fh )
12671271
1272+ classInfo = omc .sendExpression ('getClassInformation({0})' .format (package ))
1273+ baseDir = os .path .dirname (classInfo [5 ])
12681274 modelica_classes = omc .sendExpression ('getClassNames(' + package + ', recursive=true, qualified=true, sort=true)' )
12691275 for modelica_class in modelica_classes :
12701276 logger .info ('Exporting: ' + modelica_class )
0 commit comments