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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/cherrypy/favicon.ico ('k') | third_party/cherrypy/lib/auth.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/cherrypy/lib/__init__.py
===================================================================
--- third_party/cherrypy/lib/__init__.py (revision 0)
+++ third_party/cherrypy/lib/__init__.py (revision 0)
@@ -0,0 +1,45 @@
+"""CherryPy Library"""
+
+# Deprecated in CherryPy 3.2 -- remove in CherryPy 3.3
+from cherrypy.lib.reprconf import unrepr, modules, attributes
+
+class file_generator(object):
+ """Yield the given input (a file object) in chunks (default 64k). (Core)"""
+
+ def __init__(self, input, chunkSize=65536):
+ self.input = input
+ self.chunkSize = chunkSize
+
+ def __iter__(self):
+ return self
+
+ def __next__(self):
+ chunk = self.input.read(self.chunkSize)
+ if chunk:
+ return chunk
+ else:
+ if hasattr(self.input, 'close'):
+ self.input.close()
+ raise StopIteration()
+ next = __next__
+
+def file_generator_limited(fileobj, count, chunk_size=65536):
+ """Yield the given file object in chunks, stopping after `count`
+ bytes has been emitted. Default chunk size is 64kB. (Core)
+ """
+ remaining = count
+ while remaining > 0:
+ chunk = fileobj.read(min(chunk_size, remaining))
+ chunklen = len(chunk)
+ if chunklen == 0:
+ return
+ remaining -= chunklen
+ yield chunk
+
+def set_vary_header(response, header_name):
+ "Add a Vary header to a response"
+ varies = response.headers.get("Vary", "")
+ varies = [x.strip() for x in varies.split(",") if x.strip()]
+ if header_name not in varies:
+ varies.append(header_name)
+ response.headers['Vary'] = ", ".join(varies)
Property changes on: third_party/cherrypy/lib/__init__.py
___________________________________________________________________
Added: svn:eol-style
+ LF
« 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