180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205 |
# OS shell command escaping
#
def quote(ins):
if type(ins) is list:
return " ".join([quote(s) for s in ins])
# Windows: double quotes
elif conf.windows:
if re.search(r"""[()<>&%!^'";\s]""", ins):
ins = re.sub(r"([()<>&%^])", "^$1", ins)
ins = ins.replace('"', '\\^"')
return '"%s"' % ins
else:
return subprocess.list2cmdline([ins])
# Posix-style shell quoting
else:
return pipes.quote(ins)
return "%r" % ins
# Convert e.g. "text/x-scpls" MIME types to just "pls" monikers
#
def listfmt(t = "pls"):
return listfmt_t.get(t, t) # e.g. "pls" or still "text/x-unknown"
|
|
|
|
|
>
>
>
|
|
| 180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208 |
# OS shell command escaping
#
def quote(ins):
if type(ins) is list:
return " ".join([quote(s) for s in ins])
# Windows: double quotes / caret escaping
elif conf.windows:
if re.search(r"""[()<>&%!^'";\s]""", ins):
ins = '"%s"' % ins
ins = re.sub(r'([()<>"&%^])', r"^\1", ins)
return ins
else:
return subprocess.list2cmdline([ins])
# Posix-style shell quoting
else:
if re.match("^\w[\w.:/\-]+$", ins):
return ins
else:
return pipes.quote(ins)
#return "%r" % ins
# Convert e.g. "text/x-scpls" MIME types to just "pls" monikers
#
def listfmt(t = "pls"):
return listfmt_t.get(t, t) # e.g. "pls" or still "text/x-unknown"
|