• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(29193)  |  Call(21107)  |  Derive(373)  |  Import(7713)
class StringIO([buffer])

When a StringIO object is created, it can be initialized to an existing
string by passing the string to the constructor. If no string is given,
the StringIO will start empty.

The StringIO object can accept either Unicode or 8-bit strings, but
mixing the two may take some care. If both are used, 8-bit strings that
cannot be interpreted as 7-bit ASCII (that use the 8th bit) will cause
a UnicodeError to be raised when getvalue() is called.

src/b/r/braintree_python_examples-HEAD/tr_checkout_app_engine/web/browser.py   braintree_python_examples(Download)
 
import httplib, urllib, urllib2
import copy
from StringIO import StringIO
 
DEBUG = False
 
    def get_response(self):
        """Returns a copy of the current response."""
        return urllib.addinfourl(StringIO(self.data), self._response.info(), self._response.geturl())
 
    def get_soup(self):
        """Returns beautiful soup of the current document."""
        import BeautifulSoup
    def _make_response(self, result, url):
        data = "\r\n".join(["%s: %s" % (k, v) for k, v in result.header_items])
        headers = httplib.HTTPMessage(StringIO(data))
        response = urllib.addinfourl(StringIO(result.data), headers, url)
        code, msg = result.status.split(None, 1)
        response.code, response.msg = int(code), msg
        return response

src/n/i/NiPy-OLD-HEAD/examples/fiac/fiac_util.py   NiPy-OLD(Download)
# Stdlib
import os
 
from StringIO import StringIO
from os import makedirs, listdir
from os.path import exists, abspath, isdir, join as pjoin
 
        X, cons = design.stack_designs((X_exper, cons_exper),
                                       (X_initial, {}))
 
        Xf = np.loadtxt(StringIO(FIACdesigns.designs[dtype]))
        for i in range(X.shape[1]):
            yield nitest.assert_true, (matchcol(X[:,i], Xf.T)[1] > 0.999)
 
    # more in the form of a 2-way ANOVA
 
    eventdict = {1:'SSt_SSp', 2:'SSt_DSp', 3:'DSt_SSp', 4:'DSt_DSp'}
    s = StringIO()
    w = csv.writer(s)
    w.writerow(['time', 'sentence', 'speaker'])
 

src/n/i/nipy-HEAD/examples/fiac/fiac_util.py   nipy(Download)
# Stdlib
import os
 
from StringIO import StringIO
from os import makedirs, listdir
from os.path import exists, abspath, isdir, join as pjoin
 
        X, cons = design.stack_designs((X_exper, cons_exper),
                                       (X_initial, {}))
 
        Xf = np.loadtxt(StringIO(FIACdesigns.designs[dtype]))
        for i in range(X.shape[1]):
            yield nitest.assert_true, (matchcol(X[:,i], Xf.T)[1] > 0.999)
 
    # more in the form of a 2-way ANOVA
 
    eventdict = {1:'SSt_SSp', 2:'SSt_DSp', 3:'DSt_SSp', 4:'DSt_DSp'}
    s = StringIO()
    w = csv.writer(s)
    w.writerow(['time', 'sentence', 'speaker'])
 

src/v/e/velocikit-HEAD/trunk/src/velocikit/apyax/examples/file_download/downloadit.py   velocikit(Download)
def downloadImage(apyax,key):
 
    if images.has_key(key):
        filecontents = StringIO.StringIO(images[key][0])
        return (filecontents,"image/"+images[key][1])
    else:
        filecontents = StringIO.StringIO(image_download)

src/l/a/Langtangen-HEAD/src/py/examples/simviz/inputfile_wunits.py   Langtangen(Download)
def _test():
    from StringIO import StringIO
    ifile = StringIO("""\
set gridfile = somefile.grid
set add boundary indicator nodes = n=1 b4=[0,1]x[-2,-2]
set time step = 0.5 h ! [s]
set heat heatflux 1 = 0.01  ! [K/m]
ok  ! return back to previous level
ok
ok
""")
    parsed_lines, dummy = parse_input_file(ifile.readlines())
    import pprint
    print 'parsed_lines:\n', pprint.pformat(parsed_lines)

src/v/e/velocikit-HEAD/src/velocikit/apyax/examples/file_download/downloadit.py   velocikit(Download)
def downloadImage(apyax,key):
 
    if images.has_key(key):
        filecontents = StringIO.StringIO(images[key][0])
        return (filecontents,"image/"+images[key][1])
    else:
        filecontents = StringIO.StringIO(image_download)

src/p/y/pyaeso-0.5/examples/marketgraphs.py   pyaeso(Download)
import os
import os.path
import math
from StringIO import StringIO
 
# Plotting libraries
NUMPY = 'numpy'
def download_and_create_figure_data(start_date, end_date):
    '''Download raw csv files, process them, and return data necessary
    for drawing the figure.'''
 
    # Download data from website and buffer it
    f = StringIO()
    ets.dump_pool_price(f, start_date, end_date)
    # calling dump_pool_price each time.
 
    # Create data necessary for drawing
    f = StringIO(csvdata)
    data = create_figure_data(f)
    f.close()
 

src/c/r/crayons-HEAD/ext/font_engine/examples/render.py   crayons(Download)
    import StringIO
    s = f.read()
    f.close()
    f = StringIO.StringIO(s)
 
face = ft2.Face(lib, f, 0)
if attach:
    f = open(attach)
    if strio:
        s = f.read()
        f.close()
        f = StringIO.StringIO(s)

src/p/y/python-cookbook-HEAD/cb2_examples/cb2_2_10_exm_1.py   python-cookbook(Download)
import zipfile
try:
    from cStringIO import StringIO
except ImportError:
    from StringIO import StringIO
class ZipString(ZipFile):
    def __init__(self, datastring):
        ZipFile.__init__(self, StringIO(datastring))

src/p/o/pony-build-HEAD/examples/push-cgi-notifier/feedparser.py   pony-build(Download)
try:
    from cStringIO import StringIO as _StringIO
except:
    from StringIO import StringIO as _StringIO
 
# ---------- optional modules (feedparser will work without these, but with reduced functionality) ----------
 
        pass
 
    # treat url_file_stream_or_string as string
    return _StringIO(str(url_file_stream_or_string))
 
_date_handlers = []
def registerDateHandler(func):
        saxparser.setContentHandler(feedparser)
        saxparser.setErrorHandler(feedparser)
        source = xml.sax.xmlreader.InputSource()
        source.setByteStream(_StringIO(data))
        if hasattr(saxparser, '_ns_stack'):
            # work around bug in built-in SAX parser (doesn't recognize xml: namespace)
            # PyXML doesn't have this problem, and it doesn't have _ns_stack either

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next