[PyQt] Re: Copying Directory structure from a template one

F.A. Pinkse fapinkse at gmail.com
Wed Apr 8 18:08:46 BST 2009


Hello Dimitrius and mir amicitas.

Thank you for pointing out this alternative, too busy with PyQt I think. :-)

mir amicitas wrote:
> I agree that using some of the python natives would probably be easier
> that using a QDirModel.  Here is some sample code for a directory
> walker (you can find more of these online).  It would be relatively
> easy to os.path.relpath to get the structure relative to your base
> path, then to use os.path.join and os.mkdir to make the new structure.
> 
> Amicitas
> 
> On Wed, Apr 8, 2009 at 8:24 AM, Demetrius Cassidy
> <dcassidy36 at mass.rr.com> wrote:
>> I must admit I am not very familiar with QDirModel, but why not use os.walk?
>>
>> #top would be the root directory you are begining your search at.
>>  def _walkDirPath(self, top):
>>       for dirpath, dirnames, filenames in os.walk(top):
>>           for name in filenames:
>>               # yields: c:\mydata\myfile.exe
>>               yield os.path.join(dirpath, name), name
>> ----- Original Message ----- From: "F.A. Pinkse" <fapinkse at gmail.com>
>> To: <pyqt at riverbankcomputing.com>
>> Sent: Wednesday, April 08, 2009 10:52 AM
>> Subject: [PyQt] Copying Directory structure from a template one
>>
>>
>>> Hello All,
>>>
>>> For very new job in my CAD work I make a copy of an old Job Directory
>>> structure and rename the directories/files as needed by hand.
>>> Finally I decided to throw Python at it.
>>> I hard coded the structure, but I felt I could do better, like copying a
>>> template and do a rename in the process.
>>> But somehow I got stuck.
>>>
>>> Here is what I did so far.
>>>
>>> Used the QDirModel(), giving me the whole file system.
>>> Using filters will narrow this down, right?
>>> I can do a .hasChildren(), but I fail on the . findChildren() bit which is
>>> needed for navigation, I think.
>>>
>>>
>>> Has anyone a good source of examples on this.
>>>
>>> Thanks,
>>>
>>>
>>> Frans.
>>>
>>> _______________________________________________
>>> PyQt mailing list    PyQt at riverbankcomputing.com
>>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>> _______________________________________________
>> PyQt mailing list    PyQt at riverbankcomputing.com
>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>>



More information about the PyQt mailing list