Obtaining the attributes and properties of a folder recursively.

Tim Golden mail at timgolden.me.uk
Sat Mar 21 08:10:21 CET 2009

venutaurus539 at gmail.com wrote:
> On Mar 20, 6:58 pm, Tim Golden <m... at timgolden.me.uk> wrote:
>> venutaurus... at gmail.com wrote:
>>> Thank you for your suggestion but.. I'll have around 1000 such files
>>> in the whole directory and it becomes hard to manage such output
>>> because again I've to take this snapshot before backing up the data
>>> and have to do the same and compare both when the data gets restored,
>>> just to verify whether the restore happened successfully or not.
>> The .dump is simply a way of seeing quickly what the data is.
>> If you want to store is somewhere (.csv or whatever), you can
>> just select the attributes you want. Note, though, that ACLs
>> are tricky to compare. Something like the following might do
>> what you want, perhaps?
>> <code>
>> import os
>> import csv
>> from winsys import fs
>> with open ("info.csv", "wb") as f:
>>   writer = csv.writer (f)
>>   for f in fs.flat ("c:/temp/cabsdk"):
>>     print f
>>     writer.writerow ([
>>       f,
>>       f.created_at,
>>       f.written_at,
>>       f.attributes,
>>       f.security (),
>>       f.size
>>     ])
>> os.startfile ("info.csv")
>> </code>
>> This uses the security's SDDL representation, which while
>> opaque does at least give you a before-and-after check.
>> TJG
> Thank you Sir for your reply. It is working for me. But is failing if
> I have Unicode characters in my path. I tried giving a 'u' in front of
> the path but still it fails at f.createdat. Does it support Unicode
> Characters?

It certainly *should*: one of the design intentions is to
support unicode throughout (as well as trying to be robust
in the face of errors). I'll try to look at that later

You might ultimately decide that you didn't want an
in-development package as part of your app, but at
least you can look at the code inside to see how it
does what it does -- none of which is very sophisticated --
and use what you need for your own project.


More information about the Python-list mailing list