Re: [Scons-dev] Proper way to get File path (undocumented rfile)
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.reinh...@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 > 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@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@scons.org > https://pairlist2.pair.net/mailman/listinfo/scons-dev > > -- Gary ___ Scons-dev mailing list Scons-dev@scons.org https://pairlist2.pair.net/mailman/listinfo/scons-dev
Re: [Scons-dev] Proper way to get File path (undocumented rfile)
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 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@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@scons.org https://pairlist2.pair.net/mailman/listinfo/scons-dev
[Scons-dev] Proper way to get File path (undocumented rfile)
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@scons.org https://pairlist2.pair.net/mailman/listinfo/scons-dev