better safe than sorry is what I like :)

regards
stefan



On Mon, Feb 4, 2013 at 9:38 PM, Eric Thivierge <[email protected]> wrote:

> Thanks for the tips. I thought that without specifying the mode it
> defaulted to 777.
>
> --------------------------------------------
> Eric Thivierge
> http://www.ethivierge.com
>
>
> On Mon, Feb 4, 2013 at 3:36 PM, Stefan Andersson <[email protected]>wrote:
>
>> Thanks Eric! it was the enumerate that I forgot to use! Ahh....
>>
>> I would like to add a suggestion though.
>>
>>         if not os.path.isdir(oNewDir):
>>
>>
>>             os.mkdir(oNewDir)
>>         else:
>>             print oNewDir + " already exists"
>>
>>
>> Instead use this to set a mode also which is important if you use linux
>> or osx, and makedirs can create more than one directory at a time.
>>
>>
>>         try:
>>             os.makedirs(oNewDir, 0775)
>>         except:
>>             print oNewDir + " already exists"
>>
>>             pass
>>
>>
>> best regards
>> stefan
>>
>>
>>
>>
>> On Mon, Feb 4, 2013 at 9:01 PM, Eric Thivierge <[email protected]>wrote:
>>
>>> Because I have nothing better to do with my time right now and I wanted
>>> to do this at some point anyway:
>>> https://gist.github.com/4709191
>>>
>>> You may need to switch up lines 20 and 21 if you intend to read in an
>>> actual XML file (which you probably will) but you can look at the
>>> ElementTree docs in that case.
>>>
>>> --------------------------------------------
>>> Eric Thivierge
>>> http://www.ethivierge.com
>>>
>>>
>>> On Sun, Feb 3, 2013 at 9:13 PM, Raffaele Fragapane <
>>> [email protected]> wrote:
>>>
>>>> xml is fine to deal with structures such as directories 1:1.
>>>> Have a look at Python's element tree (etree), it will get you a lot
>>>> closer as it's the module intended for use with tree-like abstraction and
>>>> reconsolidation.
>>>>
>>>>
>>>> On Mon, Feb 4, 2013 at 10:05 AM, Stefan Andersson 
>>>> <[email protected]>wrote:
>>>>
>>>>> Hi All,
>>>>>
>>>>> I'm having a minor brain melt down... I know I have done this before,
>>>>> but my brain is not co-operating with me today.
>>>>>
>>>>> I have a xml file that kind of looks like this
>>>>>
>>>>> <dir>
>>>>> <dir name="images">
>>>>> <dir name="nuke" />
>>>>> <dir name="maya" />
>>>>> </dir>
>>>>> <dir name="cache">
>>>>> <dir name="sim">
>>>>> <dir name="ice" />
>>>>> <dir name="nucleus" />
>>>>>  </dir>
>>>>> </dir>
>>>>> </dir>
>>>>>
>>>>>
>>>>> And I'm trying to use xml.dom.minidom to create a folder structure
>>>>> from it... and I can't seem to be able to extract the hierarchy. The
>>>>> problem I have right now is to catch on how deep each folder is. Any
>>>>> suggestion would be most helpful right now as I'm feeling old and stupid 
>>>>> :)
>>>>> Maybe xml isn't the way to go when constructing complex folder structures.
>>>>> Anyhow, any input would be most helpful.
>>>>>
>>>>> best regards
>>>>> stefan
>>>>>
>>>>>
>>>>> --
>>>>> *Stefan Andersson | Digital Janitor*
>>>>> blog <http://sanders3d.wordpress.com> | 
>>>>> showreel<http://vimeo.com/sanders3d>|
>>>>> twitter <http://twitter.com/sanders3d> | 
>>>>> LinkedIn<http://www.linkedin.com/in/sanders3d>| cell:
>>>>> +46-73-6268850 | skype:sanders3d
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Our users will know fear and cower before our software! Ship it! Ship
>>>> it and let them flee like the dogs they are!
>>>>
>>>
>>>
>>
>>
>> --
>> *Stefan Andersson | Digital Janitor*
>> blog <http://sanders3d.wordpress.com> | showreel<http://vimeo.com/sanders3d>|
>> twitter <http://twitter.com/sanders3d> | 
>> LinkedIn<http://www.linkedin.com/in/sanders3d>| cell:
>> +46-73-6268850 | skype:sanders3d
>>
>>
>>
>


-- 
*Stefan Andersson | Digital Janitor*
blog <http://sanders3d.wordpress.com> | showreel<http://vimeo.com/sanders3d>|
twitter <http://twitter.com/sanders3d> |
LinkedIn<http://www.linkedin.com/in/sanders3d>| cell: +46-73-6268850 |
skype:sanders3d

Reply via email to