Good morning/afternoon! Is there any chance of getting shellwords[1] into Python 2.3? It's very small module with a pretty interesting functionality: [niemeyer@localhost ..-shellwords-0.2]% python Python 2.2.2 (#1, Apr 10 2003, 13:50:16) [GCC 3.2.2] on linux-ppc Type "help", "copyright", "credits" or "license" for more information.
import shellwords shellwords.shellwords('arg "arg arg" arg "arg" -o="arg arg"') ['arg', 'arg arg', 'arg', 'arg', '-o=arg arg']
[1] http://www.crazy-compilers.com/py-lib/shellwords.html -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ]
Gustavo> Is there any chance of getting shellwords[1] into Python 2.3? Can shlex not be convinced to do what you want? (Yes, I saw your Q/A, but didn't quite understand it.) Skip
Gustavo> Is there any chance of getting shellwords[1] into Python 2.3?
Can shlex not be convinced to do what you want? (Yes, I saw your Q/A, but didn't quite understand it.)
I haven't tried, but it surely can, subclassing and rewritting portions of it. OTOH, shellwords is about half the size of shlex, and shlex looks overly complex for something simple like args = shellwords(line) Btw, it wasn't *my* Q/A, I haven't written shellwords. -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ]
Can shlex not be convinced to do what you want? (Yes, I saw your Q/A, but didn't quite understand it.)
Oh, sorry. Just now I noticed that you didn't *understand* it. He was talking about that:
s = StringIO.StringIO("foo 'bar'asd'foo'") l = shlex.shlex(s) l. l.__class__ l.error_leader l.pop_source l.source l.__doc__ l.filestack l.push_source l.sourcehook l.__init__ l.get_token l.push_token l.state l.__module__ l.infile l.pushback l.token l.commenters l.instream l.quotes l.whitespace l.debug l.lineno l.read_token l.wordchars l.read_token() 'foo' l.read_token() "'bar'" l.read_token() "asd'foo'"
In constrast to:
shellwords.shellwords("foo 'bar'asd'foo'") ['foo', 'barasdfoo']
And also: [niemeyer@localhost ~/src]% echo foo 'bar'asd'foo' foo barasdfoo -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ]
On 16 April 2003, Gustavo Niemeyer said:
Is there any chance of getting shellwords[1] into Python 2.3? It's very small module with a pretty interesting functionality:
It's already there (and has been since Python 1.6), albeit with a different name and implementation:
import distutils.util distutils.util.split_quoted('arg "arg arg" arg "arg" -o="arg arg"') ['arg', 'arg arg', 'arg', 'arg', '-o=arg arg']
Greg
--
Greg Ward
On Sat, 2003-04-19 at 12:15, Greg Ward wrote:
On 16 April 2003, Gustavo Niemeyer said:
Is there any chance of getting shellwords[1] into Python 2.3? It's very small module with a pretty interesting functionality:
It's already there (and has been since Python 1.6), albeit with a different name and implementation:
import distutils.util distutils.util.split_quoted('arg "arg arg" arg "arg" -o="arg arg"') ['arg', 'arg arg', 'arg', 'arg', '-o=arg arg']
Distutils has a lot of neat (undocumented <wink>) stuff! I wonder if it makes sense to start promoting some of the more generally useful stuff up into library modules of their own? -Barry
Barry Warsaw
On Sat, 2003-04-19 at 12:15, Greg Ward wrote:
On 16 April 2003, Gustavo Niemeyer said:
Is there any chance of getting shellwords[1] into Python 2.3? It's very small module with a pretty interesting functionality:
It's already there (and has been since Python 1.6), albeit with a different name and implementation:
import distutils.util distutils.util.split_quoted('arg "arg arg" arg "arg" -o="arg arg"') ['arg', 'arg arg', 'arg', 'arg', '-o=arg arg']
Distutils has a lot of neat (undocumented <wink>) stuff! I wonder if it makes sense to start promoting some of the more generally useful stuff up into library modules of their own?
Yes. Particularly the file-manipulation stuff... shutil tends to lose somewhat x-platform. I probably first said this two or more years ago... still haven't done anythin about it :-/ Cheers, M. -- Java sucks. [...] Java on TV set top boxes will suck so hard it might well inhale people from off their sofa until their heads get wedged in the card slots. --- Jon Rabone, ucam.chat
On 19 April 2003, Barry Warsaw said:
Distutils has a lot of neat (undocumented <wink>) stuff! I wonder if it makes sense to start promoting some of the more generally useful stuff up into library modules of their own?
Probably. All the generally-useful stuff is documented in clear,
concise docstrings, so any enterprising hacker could take this on. I
still don't have enough round tuits to look at the Distutils again.
(Let's see ... my distutils-sig folder has 937 unread messages right
now... sigh...)
Greg
--
Greg Ward
It's already there (and has been since Python 1.6), albeit with a different name and implementation:
import distutils.util distutils.util.split_quoted('arg "arg arg" arg "arg" -o="arg arg"') ['arg', 'arg arg', 'arg', 'arg', '-o=arg arg']
I wasn't aware about it. While it should be enough for most uses, it's still not posix compliant. Single and double quotes are treated the same way (single quotes shouldn't allow escaping), and escaping is done differently (r'"\""' results in r'\"' instead of '"', and r'"\\"' results in r'\\' instead of r'\', for example). As others have said, it'd be nice to have these utilities somewhere outside distutils. -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ]
Michael Hudson wrote Particularly the file-manipulation stuff... shutil tends to lose somewhat x-platform.
The other file manipulation thingy that would be good would be to
abstract out the bits of tarfile and zipfile and make a standard
interface to the two.
Anthony
--
Anthony Baxter
Particularly the file-manipulation stuff... shutil tends to lose somewhat x-platform.
The other file manipulation thingy that would be good would be to abstract out the bits of tarfile and zipfile and make a standard interface to the two.
IIRC, tarfile has a wrapper which makes it compatible with zipfile. -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ]
Gustavo Niemeyer wrote The other file manipulation thingy that would be good would be to abstract out the bits of tarfile and zipfile and make a standard interface to the two.
IIRC, tarfile has a wrapper which makes it compatible with zipfile.
Yah, but tarfile's interface is much nicer. I was talking about a mode that makes zipfile like tarfile. Anthony
participants (6)
-
Anthony Baxter
-
Barry Warsaw
-
Greg Ward
-
Gustavo Niemeyer
-
Michael Hudson
-
Skip Montanaro