1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
<html xmlns="http://www.w3.org/1999/xhtml">
7
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9
<title>18.16. uu — Encode and decode uuencode files — Python 2.7.12 documentation</title>
11
<link rel="stylesheet" href="../_static/classic.css" type="text/css" />
12
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
14
<script type="text/javascript">
15
var DOCUMENTATION_OPTIONS = {
18
COLLAPSE_INDEX: false,
23
<script type="text/javascript" src="../_static/jquery.js"></script>
24
<script type="text/javascript" src="../_static/underscore.js"></script>
25
<script type="text/javascript" src="../_static/doctools.js"></script>
26
<script type="text/javascript" src="../_static/sidebar.js"></script>
27
<link rel="search" type="application/opensearchdescription+xml"
28
title="Search within Python 2.7.12 documentation"
29
href="../_static/opensearch.xml"/>
30
<link rel="author" title="About these documents" href="../about.html" />
31
<link rel="copyright" title="Copyright" href="../copyright.html" />
32
<link rel="top" title="Python 2.7.12 documentation" href="../contents.html" />
33
<link rel="up" title="18. Internet Data Handling" href="netdata.html" />
34
<link rel="next" title="19. Structured Markup Processing Tools" href="markup.html" />
35
<link rel="prev" title="18.15. quopri — Encode and decode MIME quoted-printable data" href="quopri.html" />
36
<link rel="shortcut icon" type="image/png" href="../_static/py.png" />
37
<script type="text/javascript" src="../_static/copybutton.js"></script>
38
<script type="text/javascript" src="../_static/version_switch.js"></script>
43
<body role="document">
44
<div class="related" role="navigation" aria-label="related navigation">
47
<li class="right" style="margin-right: 10px">
48
<a href="../genindex.html" title="General Index"
49
accesskey="I">index</a></li>
51
<a href="../py-modindex.html" title="Python Module Index"
54
<a href="markup.html" title="19. Structured Markup Processing Tools"
55
accesskey="N">next</a> |</li>
57
<a href="quopri.html" title="18.15. quopri — Encode and decode MIME quoted-printable data"
58
accesskey="P">previous</a> |</li>
59
<li><img src="../_static/py.png" alt=""
60
style="vertical-align: middle; margin-top: -1px"/></li>
61
<li><a href="https://www.python.org/">Python</a> »</li>
63
<span class="version_switcher_placeholder">2.7.12</span>
64
<a href="../index.html">Documentation</a> »
67
<li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li>
68
<li class="nav-item nav-item-2"><a href="netdata.html" accesskey="U">18. Internet Data Handling</a> »</li>
72
<div class="document">
73
<div class="documentwrapper">
74
<div class="bodywrapper">
75
<div class="body" role="main">
77
<div class="section" id="module-uu">
78
<span id="uu-encode-and-decode-uuencode-files"></span><h1>18.16. <a class="reference internal" href="#module-uu" title="uu: Encode and decode files in uuencode format."><code class="xref py py-mod docutils literal"><span class="pre">uu</span></code></a> — Encode and decode uuencode files<a class="headerlink" href="#module-uu" title="Permalink to this headline">¶</a></h1>
79
<p><strong>Source code:</strong> <a class="reference external" href="https://hg.python.org/cpython/file/2.7/Lib/uu.py">Lib/uu.py</a></p>
80
<hr class="docutils" />
81
<p>This module encodes and decodes files in uuencode format, allowing arbitrary
82
binary data to be transferred over ASCII-only connections. Wherever a file
83
argument is expected, the methods accept a file-like object. For backwards
84
compatibility, a string containing a pathname is also accepted, and the
85
corresponding file will be opened for reading and writing; the pathname <code class="docutils literal"><span class="pre">'-'</span></code>
86
is understood to mean the standard input or output. However, this interface is
87
deprecated; it’s better for the caller to open the file itself, and be sure
88
that, when required, the mode is <code class="docutils literal"><span class="pre">'rb'</span></code> or <code class="docutils literal"><span class="pre">'wb'</span></code> on Windows.</p>
89
<p id="index-0">This code was contributed by Lance Ellinghouse, and modified by Jack Jansen.</p>
90
<p>The <a class="reference internal" href="#module-uu" title="uu: Encode and decode files in uuencode format."><code class="xref py py-mod docutils literal"><span class="pre">uu</span></code></a> module defines the following functions:</p>
93
<code class="descclassname">uu.</code><code class="descname">encode</code><span class="sig-paren">(</span><em>in_file</em>, <em>out_file</em><span class="optional">[</span>, <em>name</em><span class="optional">[</span>, <em>mode</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#uu.encode" title="Permalink to this definition">¶</a></dt>
94
<dd><p>Uuencode file <em>in_file</em> into file <em>out_file</em>. The uuencoded file will have the
95
header specifying <em>name</em> and <em>mode</em> as the defaults for the results of decoding
96
the file. The default defaults are taken from <em>in_file</em>, or <code class="docutils literal"><span class="pre">'-'</span></code> and <code class="docutils literal"><span class="pre">0666</span></code>
100
<dl class="function">
102
<code class="descclassname">uu.</code><code class="descname">decode</code><span class="sig-paren">(</span><em>in_file</em><span class="optional">[</span>, <em>out_file</em><span class="optional">[</span>, <em>mode</em><span class="optional">[</span>, <em>quiet</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#uu.decode" title="Permalink to this definition">¶</a></dt>
103
<dd><p>This call decodes uuencoded file <em>in_file</em> placing the result on file
104
<em>out_file</em>. If <em>out_file</em> is a pathname, <em>mode</em> is used to set the permission
105
bits if the file must be created. Defaults for <em>out_file</em> and <em>mode</em> are taken
106
from the uuencode header. However, if the file specified in the header already
107
exists, a <a class="reference internal" href="#uu.Error" title="uu.Error"><code class="xref py py-exc docutils literal"><span class="pre">uu.Error</span></code></a> is raised.</p>
108
<p><a class="reference internal" href="#uu.decode" title="uu.decode"><code class="xref py py-func docutils literal"><span class="pre">decode()</span></code></a> may print a warning to standard error if the input was produced
109
by an incorrect uuencoder and Python could recover from that error. Setting
110
<em>quiet</em> to a true value silences this warning.</p>
113
<dl class="exception">
115
<em class="property">exception </em><code class="descclassname">uu.</code><code class="descname">Error</code><a class="headerlink" href="#uu.Error" title="Permalink to this definition">¶</a></dt>
116
<dd><p>Subclass of <a class="reference internal" href="exceptions.html#exceptions.Exception" title="exceptions.Exception"><code class="xref py py-exc docutils literal"><span class="pre">Exception</span></code></a>, this can be raised by <a class="reference internal" href="#uu.decode" title="uu.decode"><code class="xref py py-func docutils literal"><span class="pre">uu.decode()</span></code></a> under
117
various situations, such as described above, but also including a badly
118
formatted header, or truncated input file.</p>
121
<div class="admonition seealso">
122
<p class="first admonition-title">See also</p>
123
<dl class="last docutils">
124
<dt>Module <a class="reference internal" href="binascii.html#module-binascii" title="binascii: Tools for converting between binary and various ASCII-encoded binary representations."><code class="xref py py-mod docutils literal"><span class="pre">binascii</span></code></a></dt>
125
<dd>Support module containing ASCII-to-binary and binary-to-ASCII conversions.</dd>
134
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
135
<div class="sphinxsidebarwrapper">
136
<h4>Previous topic</h4>
137
<p class="topless"><a href="quopri.html"
138
title="previous chapter">18.15. <code class="docutils literal"><span class="pre">quopri</span></code> — Encode and decode MIME quoted-printable data</a></p>
140
<p class="topless"><a href="markup.html"
141
title="next chapter">19. Structured Markup Processing Tools</a></p>
143
<ul class="this-page-menu">
144
<li><a href="../bugs.html">Report a Bug</a></li>
145
<li><a href="../_sources/library/uu.txt"
146
rel="nofollow">Show Source</a></li>
149
<div id="searchbox" style="display: none" role="search">
150
<h3>Quick search</h3>
151
<form class="search" action="../search.html" method="get">
152
<input type="text" name="q" />
153
<input type="submit" value="Go" />
154
<input type="hidden" name="check_keywords" value="yes" />
155
<input type="hidden" name="area" value="default" />
157
<p class="searchtip" style="font-size: 90%">
158
Enter search terms or a module, class or function name.
161
<script type="text/javascript">$('#searchbox').show(0);</script>
164
<div class="clearer"></div>
166
<div class="related" role="navigation" aria-label="related navigation">
169
<li class="right" style="margin-right: 10px">
170
<a href="../genindex.html" title="General Index"
173
<a href="../py-modindex.html" title="Python Module Index"
176
<a href="markup.html" title="19. Structured Markup Processing Tools"
179
<a href="quopri.html" title="18.15. quopri — Encode and decode MIME quoted-printable data"
181
<li><img src="../_static/py.png" alt=""
182
style="vertical-align: middle; margin-top: -1px"/></li>
183
<li><a href="https://www.python.org/">Python</a> »</li>
185
<span class="version_switcher_placeholder">2.7.12</span>
186
<a href="../index.html">Documentation</a> »
189
<li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li>
190
<li class="nav-item nav-item-2"><a href="netdata.html" >18. Internet Data Handling</a> »</li>
194
© <a href="../copyright.html">Copyright</a> 1990-2016, Python Software Foundation.
196
The Python Software Foundation is a non-profit corporation.
197
<a href="https://www.python.org/psf/donations/">Please donate.</a>
199
Last updated on Sep 20, 2016.
200
<a href="../bugs.html">Found a bug</a>?
202
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.3.
b'\\ No newline at end of file'