Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5e97c9d

Browse files
committed
Adding libshlex and libnetrc by Eric Raymond.
1 parent a7d9bdf commit 5e97c9d

3 files changed

Lines changed: 126 additions & 0 deletions

File tree

Doc/lib/lib.tex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ \chapter*{Front Matter\label{front}}
116116
\input{libfileinput}
117117
\input{libcalendar}
118118
\input{libcmd}
119+
\input{libshlex}
119120

120121
\input{liballos} % Generic Operating System Services
121122
\input{libos}
@@ -192,6 +193,7 @@ \chapter*{Front Matter\label{front}}
192193
\input{libquopri}
193194
\input{libmailbox}
194195
\input{libmimify}
196+
\input{libnetrc}
195197

196198
\input{librestricted}
197199
\input{librexec}

Doc/lib/libnetrc.tex

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
% Module and documentation by Eric S. Raymond, 21 Dec 1998
2+
\section{Standard Module \module{netrc}}
3+
\stmodindex{netrc}
4+
\label{module-netrc}
5+
6+
The \code{netrc} class parses and encapsulates the netrc file format
7+
used by Unix's ftp(1) and other FTP clientd
8+
9+
\begin{classdesc}{netrc}{\optional{file}}
10+
A \class{netrc} instance or subclass instance enapsulates data from
11+
a netrc file. The initialization argument, if present, specifies the file
12+
to parse. If no argument is given, the file .netrc in the user's home
13+
directory will be read. Parse errors will throw a SyntaxError
14+
exception with associated diagnostic information including the file
15+
name, line number, and terminating token.
16+
\end{classdesc}
17+
18+
\subsection{netrc Objects}
19+
\label{netrc-objects}
20+
21+
A \class{netrc} instance has the following methods:
22+
23+
\begin{methoddesc}{authenticators}{}
24+
Return a 3-tuple (login, account, password) of authenticators for the
25+
given host. If the netrc file did not contain an entry for the given
26+
host, return the tuple associated with the `default' entry. If
27+
neither matching host nor default entry is available, return None.
28+
\end{methoddesc}
29+
30+
\begin{methoddesc}{__repr__}{host}
31+
Dump the class data as a string in the format of a netrc file.
32+
(This discards comments and may reorder the entries.)
33+
\end{methoddesc}
34+
35+
Instances of \class{netrc} have public instance variables:
36+
37+
\begin{memberdesc}{hosts}
38+
Dictionmary mapping host names to login/account/password tuples. The
39+
`default' entry, if any, is represented as a pseudo-host by that name.
40+
\end{memberdesc}
41+
42+
\begin{memberdesc}{macros}
43+
Dictionary mapping macro names to string lists.
44+
\end{memberdesc}
45+
46+
47+

Doc/lib/libshlex.tex

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
% Module and documentation by Eric S. Raymond, 21 Dec 1998
2+
\section{Standard Module \module{shlex}}
3+
\stmodindex{shlex}
4+
\label{module-shlex}
5+
6+
The \code{shlex} class makes it easy to write lexical analyzers for
7+
simple syntaxes resembling that of the Unix shell. This will often
8+
be useful for writing minilanguages, e.g. in run control files for
9+
Python applications.
10+
11+
\begin{classdesc}{shlex}{\optional{stream}}
12+
A \class{shlex} instance or subclass instance is a lexical analyzer
13+
object. The initialization argument, if present, specifies where to
14+
read characters from. It must be a file- or stream-like object with
15+
\method{read} and \method{readline} methods. If no argument is given,
16+
input will be taken from sys.stdin.
17+
18+
\end{classdesc}
19+
20+
\subsection{shlex Objects}
21+
\label{shlex-objects}
22+
23+
A \class{shlex} instance has the following methods:
24+
25+
\begin{methoddesc}{get_token}{}
26+
Return a token. If tokens have been stacked using \method{push_token},
27+
pop a token off the stack. Otherwise, read one from the input stream.
28+
If reading encounters an immediate end-of-file, '' is returned.
29+
\end{methoddesc}
30+
31+
\begin{methoddesc}{push_token}{str}
32+
Push the argument onto the token stack.
33+
\end{methoddesc}
34+
35+
Instances of \class{shlex} subclasses have some public instance
36+
variables which either control lexical analysis or can be used
37+
for debugging:
38+
39+
\begin{memberdesc}{commenters}
40+
The string of characters that are recognized as comment beginners.
41+
All characters from the comment beginner to end of line are ignored.
42+
Includes just '#' by default.
43+
\end{memberdesc}
44+
45+
\begin{memberdesc}{wordchars}
46+
The string of characters that will accumulate into multi-character
47+
tokens. By default, includes all ASCII alphanumerics and underscore.
48+
\end{memberdesc}
49+
50+
\begin{memberdesc}{whitespace}
51+
Characters that will be considered whitespace and skipped. Whitespace
52+
bounds tokens. By default, includes space and tab and linefeed and
53+
carriage-return.
54+
\end{memberdesc}
55+
56+
\begin{memberdesc}{quotes}
57+
Characters that will be considered string quotes. The token
58+
accumulates until the same quote is encountered again (thus, different
59+
quote types protect each other as in the shall.) By default, includes
60+
ASCII single and double quotes.
61+
\end{memberdesc}
62+
63+
Note that any character not declared to be a word character,
64+
whitespace, or a quote will be returned as a single-character token.
65+
66+
Quote and comment characters are not recognized within words. Thus,
67+
the bare words ``ain't'' and ``ain#t'' would be returned as single
68+
tokens by the default parser.
69+
70+
\begin{memberdesc}{lineno}
71+
Source line number (count of newlines seen so far plus one).
72+
\end{memberdesc}
73+
74+
\begin{memberdesc}{token}
75+
The token buffer. It may be useful to examine this when catching exceptions.
76+
\end{memberdesc}
77+

0 commit comments

Comments
 (0)