Applied patch from Frederic Peters for bug https://bugs.launchpad.net/appy/+bug/485815 and another bugfix.

This commit is contained in:
Gaetan Delannay 2010-03-25 16:34:37 +01:00
parent 1227f0ed5e
commit 3a7b5be03b
6 changed files with 78 additions and 24 deletions

View file

@ -7,7 +7,17 @@ appyPath = os.path.realpath(os.path.dirname(appy.__file__))
mimeTypes = {'odt': 'application/vnd.oasis.opendocument.text',
'doc': 'application/msword',
'rtf': 'text/rtf',
'pdf': 'application/pdf'}
'pdf': 'application/pdf'
}
mimeTypesExts = {
'application/vnd.oasis.opendocument.text': 'odt',
'application/msword' : 'doc',
'text/rtf' : 'rtf',
'application/pdf' : 'pdf',
'image/png' : 'png',
'image/jpeg' : 'jpg',
'image/gif' : 'gif'
}
# ------------------------------------------------------------------------------
class UnmarshalledObject:

View file

@ -17,7 +17,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,USA.
# ------------------------------------------------------------------------------
import os, os.path, sys, traceback
import os, os.path, sys, traceback, unicodedata
# ------------------------------------------------------------------------------
class FolderDeleter:
@ -76,4 +76,22 @@ def executeCommand(cmd, ignoreLines=None):
res = '\n'.join(keptLines)
childStdIn.close(); childStdOut.close(); childStdErr.close()
return res
# ------------------------------------------------------------------------------
unwantedChars = ('\\', '/', ':', '*', '?', '"', '<', '>', '|', ' ')
def normalizeString(s, usage='fileName'):
'''Returns a version of string p_s whose special chars have been
replaced with normal chars.'''
# We work in unicode. Convert p_s to unicode if not unicode.
if isinstance(s, str): s = s.decode('utf-8')
elif not isinstance(s, unicode): s = unicode(s)
if usage == 'fileName':
# Remove any char that can't be found within a file name under
# Windows.
res = ''
for char in s:
if char not in unwantedChars:
res += char
s = res
return unicodedata.normalize('NFKD', s).encode("ascii","ignore")
# ------------------------------------------------------------------------------