Problem in accessing files with unicode fonts.
Chris Rebert
clp2 at rebertia.com
Tue Feb 24 01:46:08 EST 2009
A. Your reason for emailing us off-list makes no sense. The list would
garner you more and about as quick responses, not to mention the value
it adds through public archiving. CC-ing us /might/ have made slight
sense.
B. This is your problem:
v = unicode(full_path,errors='skip')
I'd advise you to read the docs for `unicode`, particularly what using
'skip' as the value of `errors` does.
Good day.
- Chris
--
Follow the path of the Iguana...
http://rebertia.com
On Mon, Feb 23, 2009 at 10:31 PM, venu madhav <venutaurus539 at gmail.com> wrote:
> Hello,
> Sorry for mailing to your personal mails instead of mailing to
> the group. The reason being the intensity of the problem and time factor.
>
> Prob: I have a folder which contains files with unicode names ( Arabic,
> German etc). I am trying to obtain the attributes of those files recursively
> using win32api.getFileAttributes() function. Here is the code which i have
> for the same:
> ----------------------------------------------------------------------
> #!/usr/bin/env python
> import os
> import os.path
> import sys
> import urllib
> import win32api,string
> def findFile(dir_path):
> for name in os.listdir(dir_path):
> full_path = os.path.join(dir_path, name)
> print full_path
> if os.path.isdir(full_path):
> findFile(full_path)
> else:
> v = unicode(full_path,errors='skip')
> i = win32api.GetFileAttributes(v)
>
> findFile("F:\\DataSet\\Unicode")
> ---------------------------------------------------------------
> Now when I run this scirpt, the full_path variable which should contain the
> name of the file has "????" for non english ( I tried Arabic) characters. As
> a result the getfileattributes function is failing to recognise that file
> and is raising an exception.
> full_path: F:\DataSet\Unicode\Arabic files\Arabic??????????????????????????
> {type is str}
> v: F:\DataSet\Unicode\Arabic files\Arabic?????????????????????????? {type is
> unicode}
> TraceBack:
> Traceback (most recent call last):
> File "E:\venu\Testing Team\unitest.py", line 19, in <module>
> findFile("F:\\DataSet\\Unicode")
> File "E:\venu\Testing Team\unitest.py", line 13, in findFile
> findFile(full_path)
> File "E:\venu\Testing Team\unitest.py", line 16, in findFile
> i = win32api.GetFileAttributes(v)
> error: (123, 'GetFileAttributes', 'The filename, directory name, or volume
> label syntax is incorrect.')
>
> Waiting for your reply.
> Thank you in advance.
> Venu.
More information about the Python-list
mailing list