Re: Problem in accessing files with unicode fonts.



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@xxxxxxxxx> 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.
.



Relevant Pages

  • Re: OT - Cant we all agree????
    ... The reason is that so many decent, honorable, ... I've observed your thoughtful and measured responses to Powell over ... Jeff is who he is. ... Is he the most important design engineer in the ...
    (rec.music.classical.recordings)
  • Re: OT - Cant we all agree????
    ... posters, why is it that I keep wandering into threads which they have ... The reason is that so many decent, honorable, ... I've observed your thoughtful and measured responses to Powell over ... Is he the most important design engineer in the ...
    (rec.music.classical.recordings)
  • Re: My ideas on the "crisis"
    ... You lost, baby, etc. etc. ... We live in a system of hacks, hacks on the hacks and a really ... reason that it's a lot easier to keep track of what they're doing under ... I've actually gotten good responses from them, ...
    (alt.guitar.amps)
  • Re: An Enemy of the People
    ... incite the most responses. ... This means it is useless to reason with him in any way. ... Bacarisse in particular spends a lot of time ... and Heathfield's contributions show his limitations. ...
    (comp.programming)
  • Re: OS X compile
    ... Please do not be rude. ... I don't like Neo because he is continually, repeatedly, consistently, ... it has become since his responses to me have convinced me that he is not ... even slightly amenable to reason in this matter - and it would have ...
    (rec.games.roguelike.angband)