Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3)

Side by Side Diff: Doc/library/shlex.rst

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Doc/library/reprlib.rst ('k') | Doc/library/shutil.rst » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 :mod:`shlex` --- Simple lexical analysis 1 :mod:`shlex` --- Simple lexical analysis
2 ======================================== 2 ========================================
3 3
4 .. module:: shlex 4 .. module:: shlex
5 :synopsis: Simple lexical analysis for Unix shell-like languages. 5 :synopsis: Simple lexical analysis for Unix shell-like languages.
6 .. moduleauthor:: Eric S. Raymond <esr@snark.thyrsus.com> 6 .. moduleauthor:: Eric S. Raymond <esr@snark.thyrsus.com>
7 .. moduleauthor:: Gustavo Niemeyer <niemeyer@conectiva.com> 7 .. moduleauthor:: Gustavo Niemeyer <niemeyer@conectiva.com>
8 .. sectionauthor:: Eric S. Raymond <esr@snark.thyrsus.com> 8 .. sectionauthor:: Eric S. Raymond <esr@snark.thyrsus.com>
9 .. sectionauthor:: Gustavo Niemeyer <niemeyer@conectiva.com> 9 .. sectionauthor:: Gustavo Niemeyer <niemeyer@conectiva.com>
10 10
11 **Source code:** :source:`Lib/shlex.py` 11 **Source code:** :source:`Lib/shlex.py`
12 12
13 -------------- 13 --------------
14 14
15 The :class:`shlex` class makes it easy to write lexical analyzers for simple 15 The :class:`shlex` class makes it easy to write lexical analyzers for simple
16 syntaxes resembling that of the Unix shell. This will often be useful for 16 syntaxes resembling that of the Unix shell. This will often be useful for
17 writing minilanguages, (for example, in run control files for Python 17 writing minilanguages, (for example, in run control files for Python
18 applications) or for parsing quoted strings. 18 applications) or for parsing quoted strings.
19 19
20 The :mod:`shlex` module defines the following functions: 20 The :mod:`shlex` module defines the following functions:
21 21
22 22
23 .. function:: split(s, comments=False, posix=True) 23 .. function:: split(s, comments=False, posix=True)
24 24
25 Split the string *s* using shell-like syntax. If *comments* is :const:`False` 25 Split the string *s* using shell-like syntax. If *comments* is :const:`False`
26 (the default), the parsing of comments in the given string will be disabled 26 (the default), the parsing of comments in the given string will be disabled
27 (setting the :attr:`commenters` attribute of the :class:`shlex` instance to 27 (setting the :attr:`commenters` member of the :class:`shlex` instance to the
28 the empty string). This function operates in POSIX mode by default, but uses 28 empty string). This function operates in POSIX mode by default, but uses
29 non-POSIX mode if the *posix* argument is false. 29 non-POSIX mode if the *posix* argument is false.
30 30
31 .. note:: 31 .. note::
32 32
33 Since the :func:`split` function instantiates a :class:`shlex` instance, 33 Since the :func:`split` function instantiates a :class:`shlex` instance,
34 passing ``None`` for *s* will read the string to split from standard 34 passing ``None`` for *s* will read the string to split from standard
35 input. 35 input.
36 36
37 The :mod:`shlex` module defines the following class: 37 The :mod:`shlex` module defines the following class:
38 38
39 39
40 .. class:: shlex(instream=None, infile=None, posix=False) 40 .. class:: shlex(instream=None, infile=None, posix=False)
41 41
42 A :class:`shlex` instance or subclass instance is a lexical analyzer object. 42 A :class:`shlex` instance or subclass instance is a lexical analyzer object.
43 The initialization argument, if present, specifies where to read characters 43 The initialization argument, if present, specifies where to read characters
44 from. It must be a file-/stream-like object with :meth:`read` and 44 from. It must be a file-/stream-like object with :meth:`read` and
45 :meth:`readline` methods, or a string. If no argument is given, input will 45 :meth:`readline` methods, or a string. If no argument is given, input will
46 be taken from ``sys.stdin``. The second optional argument is a filename 46 be taken from ``sys.stdin``. The second optional argument is a filename
47 string, which sets the initial value of the :attr:`infile` attribute. If the 47 string, which sets the initial value of the :attr:`infile` member. If the
48 *instream* argument is omitted or equal to ``sys.stdin``, this second 48 *instream* argument is omitted or equal to ``sys.stdin``, this second
49 argument defaults to "stdin". The *posix* argument defines the operational 49 argument defaults to "stdin". The *posix* argument defines the operational
50 mode: when *posix* is not true (default), the :class:`shlex` instance will 50 mode: when *posix* is not true (default), the :class:`shlex` instance will
51 operate in compatibility mode. When operating in POSIX mode, :class:`shlex` 51 operate in compatibility mode. When operating in POSIX mode, :class:`shlex`
52 will try to be as close as possible to the POSIX shell parsing rules. 52 will try to be as close as possible to the POSIX shell parsing rules.
53 53
54 54
55 .. seealso:: 55 .. seealso::
56 56
57 Module :mod:`configparser` 57 Module :mod:`configparser`
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 constructing error messages. 195 constructing error messages.
196 196
197 197
198 .. attribute:: shlex.instream 198 .. attribute:: shlex.instream
199 199
200 The input stream from which this :class:`shlex` instance is reading character s. 200 The input stream from which this :class:`shlex` instance is reading character s.
201 201
202 202
203 .. attribute:: shlex.source 203 .. attribute:: shlex.source
204 204
205 This attribute is ``None`` by default. If you assign a string to it, that 205 This member is ``None`` by default. If you assign a string to it, that strin g
206 string will be recognized as a lexical-level inclusion request similar to the 206 will be recognized as a lexical-level inclusion request similar to the
207 ``source`` keyword in various shells. That is, the immediately following tok en 207 ``source`` keyword in various shells. That is, the immediately following tok en
208 will opened as a filename and input taken from that stream until EOF, at whic h 208 will opened as a filename and input taken from that stream until EOF, at whic h
209 point the :meth:`close` method of that stream will be called and the input 209 point the :meth:`close` method of that stream will be called and the input
210 source will again become the original input stream. Source requests may be 210 source will again become the original input stream. Source requests may be
211 stacked any number of levels deep. 211 stacked any number of levels deep.
212 212
213 213
214 .. attribute:: shlex.debug 214 .. attribute:: shlex.debug
215 215
216 If this attribute is numeric and ``1`` or more, a :class:`shlex` instance wil l 216 If this member is numeric and ``1`` or more, a :class:`shlex` instance will
217 print verbose progress output on its behavior. If you need to use this, you can 217 print verbose progress output on its behavior. If you need to use this, you can
218 read the module source code to learn the details. 218 read the module source code to learn the details.
219 219
220 220
221 .. attribute:: shlex.lineno 221 .. attribute:: shlex.lineno
222 222
223 Source line number (count of newlines seen so far plus one). 223 Source line number (count of newlines seen so far plus one).
224 224
225 225
226 .. attribute:: shlex.token 226 .. attribute:: shlex.token
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 ``'"'``) preserves the literal value of all characters within the quotes, with 277 ``'"'``) preserves the literal value of all characters within the quotes, with
278 the exception of the characters mentioned in :attr:`escape`. The escape 278 the exception of the characters mentioned in :attr:`escape`. The escape
279 characters retain its special meaning only when followed by the quote in use, or 279 characters retain its special meaning only when followed by the quote in use, or
280 the escape character itself. Otherwise the escape character will be considered a 280 the escape character itself. Otherwise the escape character will be considered a
281 normal character. 281 normal character.
282 282
283 * EOF is signaled with a :const:`None` value; 283 * EOF is signaled with a :const:`None` value;
284 284
285 * Quoted empty strings (``''``) are allowed; 285 * Quoted empty strings (``''``) are allowed;
286 286
OLDNEW
« no previous file with comments | « Doc/library/reprlib.rst ('k') | Doc/library/shutil.rst » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+