comparison env/lib/python3.9/site-packages/shellescape-3.4.1.dist-info/METADATA @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4f3585e2f14b
1 Metadata-Version: 2.0
2 Name: shellescape
3 Version: 3.4.1
4 Summary: Shell escape a string to safely use it as a token in a shell command (backport of Python shlex.quote for Python versions 2.x & < 3.3)
5 Home-page: https://github.com/chrissimpkins/shellescape
6 Author: Christopher Simpkins
7 Author-email: git.simpkins@gmail.com
8 License: MIT license
9 Keywords: shell,quote,escape,backport,command line,command,subprocess
10 Platform: any
11 Classifier: Development Status :: 5 - Production/Stable
12 Classifier: Intended Audience :: Developers
13 Classifier: Natural Language :: English
14 Classifier: License :: OSI Approved :: MIT License
15 Classifier: Programming Language :: Python
16 Classifier: Programming Language :: Python :: 2
17 Classifier: Programming Language :: Python :: 3
18 Classifier: Operating System :: MacOS :: MacOS X
19 Classifier: Operating System :: POSIX
20 Classifier: Operating System :: Unix
21 Classifier: Operating System :: Microsoft :: Windows
22
23 Source Repository: https://github.com/chrissimpkins/shellescape
24
25 Description
26 -----------
27
28 The shellescape Python module defines the ``shellescape.quote()`` function that returns a shell-escaped version of a Python string. This is a backport of the ``shlex.quote()`` function from Python 3.4.3 that makes it accessible to users of Python 3 versions < 3.3 and all Python 2.x versions.
29
30 quote(s)
31 --------
32
33 >From the Python documentation:
34
35 Return a shell-escaped version of the string s. The returned value is a string that can safely be used as one token in a shell command line, for cases where you cannot use a list.
36
37 This idiom would be unsafe:
38
39 .. code-block:: python
40
41 >>> filename = 'somefile; rm -rf ~'
42 >>> command = 'ls -l {}'.format(filename)
43 >>> print(command) # executed by a shell: boom!
44 ls -l somefile; rm -rf ~
45
46
47 ``quote()`` lets you plug the security hole:
48
49 .. code-block:: python
50
51 >>> command = 'ls -l {}'.format(quote(filename))
52 >>> print(command)
53 ls -l 'somefile; rm -rf ~'
54 >>> remote_command = 'ssh home {}'.format(quote(command))
55 >>> print(remote_command)
56 ssh home 'ls -l '"'"'somefile; rm -rf ~'"'"''
57
58
59 The quoting is compatible with UNIX shells and with ``shlex.split()``:
60
61 .. code-block:: python
62
63 >>> remote_command = split(remote_command)
64 >>> remote_command
65 ['ssh', 'home', "ls -l 'somefile; rm -rf ~'"]
66 >>> command = split(remote_command[-1])
67 >>> command
68 ['ls', '-l', 'somefile; rm -rf ~']
69
70
71 Usage
72 -----
73
74 Include ``shellescape`` in your project setup.py file ``install_requires`` dependency definition list:
75
76 .. code-block:: python
77
78 setup(
79 ...
80 install_requires=['shellescape'],
81 ...
82 )
83
84
85 Then import the ``quote`` function into your module(s) and use it as needed:
86
87 .. code-block:: python
88
89 #!/usr/bin/env python
90 # -*- coding: utf-8 -*-
91
92 from shellescape import quote
93
94 filename = "somefile; rm -rf ~"
95 escaped_shell_command = 'ls -l {}'.format(quote(filename))
96
97
98 Issue Reporting
99 ---------------
100
101 Issue reporting is available on the `GitHub repository <https://github.com/chrissimpkins/shellescape/issues>`_
102
103
104
105