diff options
author | erikb <erikb@574bc980-5f2d-0410-acbc-c8f9f0eb14e0> | 2007-10-31 16:27:45 (GMT) |
---|---|---|
committer | erikb <erikb@574bc980-5f2d-0410-acbc-c8f9f0eb14e0> | 2007-10-31 16:27:45 (GMT) |
commit | 1ab6b11c83d527bdd02f04cccc34ef00b0494912 (patch) | |
tree | 1e2f8b2046be9a64523f3aba46fb02d0d5291369 /utils.py | |
parent | 6e20a3af2331fc524f356c981e308dd1373af112 (diff) |
refactoring
git-svn-id: http://mediamods.com/public-svn/camera-activity/Record.activity@785 574bc980-5f2d-0410-acbc-c8f9f0eb14e0
Diffstat (limited to 'utils.py')
-rw-r--r-- | utils.py | 27 |
1 files changed, 26 insertions, 1 deletions
@@ -1,4 +1,6 @@ import base64 +import rsvg +import re def getStringFromPixbuf(pixbuf): @@ -17,4 +19,27 @@ def getPixbufFromString(str): data = base64.b64decode( str ) pbl.write(data) pbl.close() - return pbl.get_pixbuf()
\ No newline at end of file + return pbl.get_pixbuf() + + +def loadSvg( data, stroke, fill ): + if ((stroke == None) or (fill == None)): + return rsvg.Handle( data=data ) + + entity = '<!ENTITY fill_color "%s">' % fill + data = re.sub('<!ENTITY fill_color .*>', entity, data) + + entity = '<!ENTITY stroke_color "%s">' % stroke + data = re.sub('<!ENTITY stroke_color .*>', entity, data) + + return rsvg.Handle( data=data ) + + +def getUniqueFilepath( path, i ): + pathOb = os.path.abspath( path ) + if (os.path.exists(pathOb)): + i = i+1 + newPath = os.path.join( os.path.dirname(pathOb), str( str(i) + os.path.basename(pathOb) ) ) + return getUniqueFilepath( str(newPath), i ) + else: + return os.path.abspath( path )
\ No newline at end of file |