Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Side by Side Diff: third_party/cherrypy/lib/__init__.py

Issue 9368042: Add CherryPy to third_party. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build/
Patch Set: '' Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/cherrypy/favicon.ico ('k') | third_party/cherrypy/lib/auth.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 """CherryPy Library"""
2
3 # Deprecated in CherryPy 3.2 -- remove in CherryPy 3.3
4 from cherrypy.lib.reprconf import unrepr, modules, attributes
5
6 class file_generator(object):
7 """Yield the given input (a file object) in chunks (default 64k). (Core)"""
8
9 def __init__(self, input, chunkSize=65536):
10 self.input = input
11 self.chunkSize = chunkSize
12
13 def __iter__(self):
14 return self
15
16 def __next__(self):
17 chunk = self.input.read(self.chunkSize)
18 if chunk:
19 return chunk
20 else:
21 if hasattr(self.input, 'close'):
22 self.input.close()
23 raise StopIteration()
24 next = __next__
25
26 def file_generator_limited(fileobj, count, chunk_size=65536):
27 """Yield the given file object in chunks, stopping after `count`
28 bytes has been emitted. Default chunk size is 64kB. (Core)
29 """
30 remaining = count
31 while remaining > 0:
32 chunk = fileobj.read(min(chunk_size, remaining))
33 chunklen = len(chunk)
34 if chunklen == 0:
35 return
36 remaining -= chunklen
37 yield chunk
38
39 def set_vary_header(response, header_name):
40 "Add a Vary header to a response"
41 varies = response.headers.get("Vary", "")
42 varies = [x.strip() for x in varies.split(",") if x.strip()]
43 if header_name not in varies:
44 varies.append(header_name)
45 response.headers['Vary'] = ", ".join(varies)
OLDNEW
« no previous file with comments | « third_party/cherrypy/favicon.ico ('k') | third_party/cherrypy/lib/auth.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698