Quote the argument for safe use in a shell command line.
(arg)
| 303 | |
| 304 | |
| 305 | def _quote_arg(arg): |
| 306 | """ |
| 307 | Quote the argument for safe use in a shell command line. |
| 308 | """ |
| 309 | # If there is a quote in the string, assume relevants parts of the |
| 310 | # string are already quoted (e.g. '-I"C:\\Program Files\\..."') |
| 311 | if '"' not in arg and ' ' in arg: |
| 312 | return '"%s"' % arg |
| 313 | return arg |
| 314 | |
| 315 | ############################################################ |