diff options
author | Sascha Silbe <sascha-pgp@silbe.org> | 2010-10-15 19:14:59 (GMT) |
---|---|---|
committer | Sascha Silbe <sascha-pgp@silbe.org> | 2010-11-23 16:14:34 (GMT) |
commit | 7acfbd070fa207dff309383da6e743ad2b9843c3 (patch) | |
tree | 662b4cb7ff5494f162365d85098e7fce7179d35e /src/sugar/network.py | |
parent | 5f13fcfc847ecff18b9558de8ce29da884a06d7a (diff) |
style cleanup: prefer ' for strings
Tomeu prefers ' for strings, so let's use it wherever we don't have a good
reason to use ".
Reviewed-by: James Cameron <quozl@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>
CC: Aleksey Lim <alsroot@member.fsf.org>
Diffstat (limited to 'src/sugar/network.py')
-rw-r--r-- | src/sugar/network.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/sugar/network.py b/src/sugar/network.py index 069a980..34d496c 100644 --- a/src/sugar/network.py +++ b/src/sugar/network.py @@ -147,12 +147,12 @@ class ChunkedGlibHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): """ path = self.translate_path(self.path) if not path or not os.path.exists(path): - self.send_error(404, "File not found") + self.send_error(404, 'File not found') return None f = None if os.path.isdir(path): - for index in "index.html", "index.htm": + for index in 'index.html', 'index.htm': index = os.path.join(path, index) if os.path.exists(index): path = index @@ -166,12 +166,12 @@ class ChunkedGlibHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): # transmitted *less* than the content-length! f = open(path, 'rb') except IOError: - self.send_error(404, "File not found") + self.send_error(404, 'File not found') return None self.send_response(200) - self.send_header("Content-type", ctype) - self.send_header("Content-Length", str(os.fstat(f.fileno())[6])) - self.send_header("Content-Disposition", 'attachment; filename="%s"' % + self.send_header('Content-type', ctype) + self.send_header('Content-Length', str(os.fstat(f.fileno())[6])) + self.send_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(path)) self.end_headers() return f @@ -209,8 +209,8 @@ class GlibURLDownloader(gobject.GObject): self._outf = None self._fname = None if destfd and not destfile: - raise ValueError("Must provide destination file too when" \ - "specifying file descriptor") + raise ValueError('Must provide destination file too when' + ' specifying file descriptor') if destfile: self._suggested_fname = os.path.basename(destfile) self._fname = os.path.abspath(os.path.expanduser(destfile)) @@ -238,15 +238,15 @@ class GlibURLDownloader(gobject.GObject): def cancel(self): if self._srcid == 0: - raise RuntimeError("Download already canceled or stopped") + raise RuntimeError('Download already canceled or stopped') self.cleanup(remove=True) def _get_filename_from_headers(self, headers): if 'Content-Disposition' not in headers: return None - ftag = "filename=" - data = headers["Content-Disposition"] + ftag = 'filename=' + data = headers['Content-Disposition'] fidx = data.find(ftag) if fidx < 0: return None @@ -260,7 +260,7 @@ class GlibURLDownloader(gobject.GObject): def _read_next_chunk(self, source, condition): if condition & gobject.IO_ERR: self.cleanup(remove=True) - self.emit("error", "Error downloading file.") + self.emit('error', 'Error downloading file.') return False elif not (condition & gobject.IO_IN): # shouldn't get here, but... @@ -274,19 +274,19 @@ class GlibURLDownloader(gobject.GObject): # error writing data to file? if count < len(data): self.cleanup(remove=True) - self.emit("error", "Error writing to download file.") + self.emit('error', 'Error writing to download file.') return False - self.emit("progress", self._written) + self.emit('progress', self._written) # done? if len(data) < self.CHUNK_SIZE: self.cleanup() - self.emit("finished", self._fname, self._suggested_fname) + self.emit('finished', self._fname, self._suggested_fname) return False except Exception, err: self.cleanup(remove=True) - self.emit("error", "Error downloading file: %s" % err) + self.emit('error', 'Error downloading file: %r' % err) return False return True |