uuDecode problem
py
codecraig at gmail.com
Wed Dec 7 11:37:57 EST 2005
Alex Martelli wrote:
> binascii.b2a_uu only works for up to 45 bytes at once; but if you were
> feeding it more than 45 bytes, this should raise a binascii.Error
> itself.
> Definitely not, given the above limit. But I still don't quite
> understand the exact mechanics of the error you're getting.
>
>
> Alex
here is an example.
def doSomething():
data = aFile.readlines()
result = []
for x in data:
result.append(encode(x))
return result
def printResult(encodedData):
"""encodedData is a list of strings which are uu encoded"""
print decode(encodedData)
encode(data):
"""data is a string"""
if len(data) > 45:
tmp = []
for c in data:
tmp.append(binascii.b2a_uu(c))
return ''.join(tmp)
else:
return binascii.b2a_uu(data)
decode(data):
"""data is a list of strings"""
result = []
for val in data
if len(val) > 45:
response = []
for x in val:
response.append(binascii.a2b_uu(x))
result.append(response)
else:
result.append(binascii.a2b_uu(val))
return ''.join(result)
...i would use those functions like
data = doSomething()
printResult(data)
Now i get this...
" response.append(binascii.a2b_uu(x))
java.lang.StringIndexOutOfBoundsException:
java.lang.StringIndexOutOfBoundsExcep
tion: String index out of range: 1"
So the error is in the decode method .....this is in Jython...perhaps
Jython doesn't handle binascii.a2b_uu ? or perhaps since the actual
data is being encoded in python, then read in and decoded in my jython
script..that could be the problem?
thanks.
More information about the Python-list
mailing list