Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/shellescape/main.py @ 2:6af9afd405e9 draft
"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
| author | shellac |
|---|---|
| date | Thu, 14 May 2020 14:56:58 -0400 |
| parents | 26e78fe6e8c4 |
| children |
comparison
equal
deleted
inserted
replaced
| 1:75ca89e9b81c | 2:6af9afd405e9 |
|---|---|
| 1 #!/usr/bin/env python | |
| 2 # -*- coding: utf-8 -*- | |
| 3 | |
| 4 import re | |
| 5 | |
| 6 | |
| 7 _find_unsafe = re.compile(r'[a-zA-Z0-9_^@%+=:,./-]').search | |
| 8 | |
| 9 | |
| 10 def quote(s): | |
| 11 """Return a shell-escaped version of the string *s*.""" | |
| 12 if not s: | |
| 13 return "''" | |
| 14 | |
| 15 if _find_unsafe(s) is None: | |
| 16 return s | |
| 17 | |
| 18 # use single quotes, and put single quotes into double quotes | |
| 19 # the string $'b is then quoted as '$'"'"'b' | |
| 20 | |
| 21 return "'" + s.replace("'", "'\"'\"'") + "'" |
