Hi Ron,

I was going to suggest os.path.normpath() to collapse /../
I'm not so sure os.path.realpath() actually does that, since it's supposed
to be used to translate symbolic links.

You could always combine the two, where you would do normpath first and
then realpath: os.path.normpath( os.path.realpath(path) )


Regards,
Fredrik



On Mon, Mar 17, 2014 at 1:38 PM, Ron Ganbar <[email protected]> wrote:

> OK, found it, this helps:
> os.path.realpath()
>
>
>
> Ron Ganbar
> email: [email protected]
> tel: +44 (0)7968 007 309 [UK]
>      +972 (0)54 255 9765 [Israel]
> url: http://ronganbar.wordpress.com/
>
>
> On Mon, Mar 17, 2014 at 2:36 PM, Ron Ganbar <[email protected]> wrote:
>
>> Hi Frederich,
>> thanks for the script. It still leaves the /../ there though.
>> Anybody ever tackle how to resolve this? If I try to run os.walk on a
>> path containing /../ it returns an error?
>>
>> Thanks
>> R
>>
>>
>>
>>
>>
>> Ron Ganbar
>> email: [email protected]
>> tel: +44 (0)7968 007 309 [UK]
>>      +972 (0)54 255 9765 [Israel]
>> url: http://ronganbar.wordpress.com/
>>
>>
>> On Mon, Mar 17, 2014 at 2:09 PM, Frederich Munch <[email protected]>wrote:
>>
>>>  I've had similar issues and found that nuke.filename isn't reliable
>>> (on Mac at least):
>>>  Only resolves when 'project_directory' is set to a value
>>>  If 'project_directory' is wrong, resolution can point to
>>> a non-existent file
>>>
>>>
>>> This gets around those issues (but might have others in relation to path
>>> remapping):
>>>
>>>
>>> def resolveNodePath(node):
>>>  if not isinstance(node, nuke.Node): node = nuke.toNode(node)
>>>  return node.knob('file').evaluate()
>>>
>>>
>>> # nuke.filename = resolveNodePath
>>>
>>>
>>>
>>>
>>> ------------------------------
>>> From: [email protected]
>>> Date: Mon, 17 Mar 2014 10:23:56 +0200
>>> To: [email protected]
>>> Subject: [Nuke-python] Project Directory
>>>
>>>
>>> Hi all,
>>> I'm using the project directory structure for relative paths in Nuke.
>>> So the Project Directory text field has: [python
>>> {nuke.script_directory()}]
>>> Then I use the ./../../path/to/file/file.jpg structure.
>>> However, now that I run scripts that call for the file path they don't
>>> work as they can't resolve the path.
>>> Any ideas how to get the full path? Is there a function in Nuke that
>>> takes care of resolving the path with the Project Directory?
>>>
>>> Thanks,
>>> Ron Ganbar
>>> email: [email protected]
>>> tel: +44 (0)7968 007 309 [UK]
>>>      +972 (0)54 255 9765 [Israel]
>>> url: http://ronganbar.wordpress.com/
>>>
>>> _______________________________________________ Nuke-python mailing list
>>> [email protected], http://forums.thefoundry.co.uk/
>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>>
>>> _______________________________________________
>>> Nuke-python mailing list
>>> [email protected], http://forums.thefoundry.co.uk/
>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>>
>>>
>>
>
> _______________________________________________
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
>
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to