[Scons-dev] Proper way to get File path (undocumented rfile)

Gary Oberbrunner garyo at oberbrunner.com
Fri Oct 2 12:53:34 EDT 2015


str(File) just calls f.path. There are also plenty of other attributes like
fullpath. Sometimes f.srcnode().path is useful. Most are documented, see
File and Directory Nodes in the man page. The ones that aren't (like rfile)
are intended for internal use but may occasionally still be useful.  See
the API docs at
http://www.scons.org/doc/latest/HTML/scons-api/SCons.Node.FS.File-class.html
for gory details.

-- Gary

On Fri, Oct 2, 2015 at 10:07 AM, Jonathon Reinhart <
jonathon.reinhart at gmail.com> wrote:

> I, too have come across scenarios where rfile() was the only way to
> accomplish exactly what I needed. I believe the scenario was this:
>
> The arguments / command-line parameters to my external utility were so
> complex, SCons couldn't handle it himself. So I wrote my own
> variable-function-thing (like ${_concat}) in which I needed to expand the
> Nodes to their paths, just like SCons would when expanding $TARGETS to
> their paths. This is how I ended up finding rfile().
>
> It seems like it should be documented.
>
>
>
>
>
> On Fri, Oct 2, 2015 at 4:15 AM, anatoly techtonik <techtonik at gmail.com>
> wrote:
>
>> Hi,
>>
>> Currently the way to get filename from File node is to str() that File.
>> That's quite shady API, especially if used in function like:
>>
>>     def convert(node):
>>         return str(node).replace('\\', '/')
>>
>> I mean you have no idea what types of node are expected and why
>> there is slash escaping. The str(node) can return anything and
>> works on any types of nodes.
>>
>> So, there is undocumented method File.rfile() with the path.
>>
>> http://www.scons.org/doc/HTML/scons-api/SCons.Node.FS.File-class.html#rfile
>> Which contains os specific path and it is used for example in
>> https://github.com/wesnoth/wesnoth/pull/481/files
>>
>> The questions.
>> 1. Why it is called rfile?
>> 2. Should it be documented?
>> 3. What should be the proper API to get path info for File node?
>> 4. What is the proper API to convert paths to system-specific and to
>> canonical (forward slash) form?
>> --
>> anatoly t.
>>
>> _______________________________________________
>> Scons-dev mailing list
>> Scons-dev at scons.org
>> https://pairlist2.pair.net/mailman/listinfo/scons-dev
>>
>>
>
>
> --
> Computers are incredibly fast, accurate and stupid. Human beings are
> incredibly slow, inaccurate and brilliant. Together they are powerful
> beyond imagination.
>                                     A. Einstein
>
> _______________________________________________
> Scons-dev mailing list
> Scons-dev at scons.org
> https://pairlist2.pair.net/mailman/listinfo/scons-dev
>
>


-- 
Gary
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/scons-dev/attachments/20151002/da1ff7a6/attachment-0001.html>


More information about the Scons-dev mailing list