'Generates a local file name based on the original
Taken from FTP decoder'

def __localfilename(self, path, origname):

    tmp = origname.replace('\\', '_')
    tmp = tmp.replace('/', '_')
    tmp = tmp.replace(':', '_')
    localname = ''
    for c in tmp:
        if ((ord(c) > 32) and (ord(c) < 127)):
            localname += c
        else:
            localname += ('%%%02X' % ord(c))
    localname = ((path + '/') + localname)
    postfix = ''
    i = 0
    while os.path.exists((localname + postfix)):
        i += 1
        postfix = ('_%02d' % i)
    return (localname + postfix)
