rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
token = self.token() elif token[0] == "sep" and token[1] == "{": d = self.mergeFunctionComment(self.name, ((type, None), self.signature), static) self.index.add(self.name, self.filename, static, | token = self.token() elif token[0] == "sep" and token[1] == "{": d = self.mergeFunctionComment(self.name, ((type, None), self.signature), static) self.index_add(self.name, self.filename, static, | def parseGlobal(self, token): static = 0 if token[1] == 'extern': token = self.token() if token == None: return token if token[0] == 'string': if token[1] == 'C': token = self.token() if token == None: |
token = self.token() token = self.parseBlock(token); elif token[1] == ',': self.comment = None self.index.add(self.name, self.filename, static, | token = self.token() token = self.parseBlock(token); elif token[1] == ',': self.comment = None self.index_add(self.name, self.filename, static, | def parseGlobal(self, token): static = 0 if token[1] == 'extern': token = self.token() if token == None: return token if token[0] == 'string': if token[1] == 'C': token = self.token() if token == None: |
return token def parse(self): print "Parsing %s" % (self.filename) token = self.token() while token != None: if token[0] == 'name': token = self.parseGlobal(token) else: self.error("token %s %s unexpected at the top level" % ( token[0], token[1])) token = self.parseGlobal(token) return return self.index | return token def parse(self): print "Parsing %s" % (self.filename) token = self.token() while token != None: if token[0] == 'name': token = self.parseGlobal(token) else: self.error("token %s %s unexpected at the top level" % ( token[0], token[1])) token = self.parseGlobal(token) return self.parseTopComment(self.top_co... | def parseGlobal(self, token): static = 0 if token[1] == 'extern': token = self.token() if token == None: return token if token[0] == 'string': if token[1] == 'C': token = self.token() if token == None: |
def __init__(self, name, directories=['.'], excludes=[]): self.name = name self.directories = directories self.excludes = excludes + ignored_files.keys() self.modules = {} self.headers = {} self.idx = index() def analyze(self): print "Project %s : %d headers, %d modules" % (self.name, len(self.headers.keys()), len(sel... | def __init__(self, name, directories=['.'], excludes=[]): self.name = name self.directories = directories self.excludes = excludes + ignored_files.keys() self.modules = {} self.headers = {} self.idx = index() self.xref = {} self.index = {} if name == 'libxml2': self.basename = 'libxml' else: self.basename = name def i... | def parse(self): print "Parsing %s" % (self.filename) token = self.token() |
def modulename_file(self, file): module = string.split(file, '/')[-1] if module[-2:] == '.h': module = module[:-2] return module def serialize_enum(self, output, name): id = self.idx.enums[name] output.write(" <enum name='%s' file='%s'" % (name, self.modulename_file(id.module))) if id.info != None: info = id.info i... | def modulename_file(self, file): module = os.path.basename(file) if module[-2:] == '.h': module = module[:-2] return module def serialize_enum(self, output, name): id = self.idx.enums[name] output.write(" <enum name='%s' file='%s'" % (name, self.modulename_file(id.module))) if id.info != None: info = id.info if inf... | def modulename_file(self, file): module = string.split(file, '/')[-1] |
output.write(">\n"); try: for field in self.idx.structs[name].info: desc = field[2] if desc == None: desc = '' else: desc = escape(desc) output.write(" <field name='%s' type='%s' info='%s'/>\n" % (field[1] , field[0], desc)) except: print "Failed to serialize struct %s" % (name) output.write(" </struct>\n") els... | output.write(">\n"); try: for field in self.idx.structs[name].info: desc = field[2] self.indexString(name, desc) if desc == None: desc = '' else: desc = escape(desc) output.write(" <field name='%s' type='%s' info='%s'/>\n" % (field[1] , field[0], desc)) except: print "Failed to serialize struct %s" % (name) output... | def serialize_typedef(self, output, name): id = self.idx.typedefs[name] |
def serialize_function(self, output, name): id = self.idx.functions[name] output.write(" <%s name='%s' file='%s'>\n" % (id.type, name, self.modulename_file(id.module))) try: (ret, params, desc) = id.info output.write(" <info>%s</info>\n" % (escape(desc))) if ret[0] != None: if ret[0] == "void": output.write(" ... | def serialize_function(self, output, name): id = self.idx.functions[name] output.write(" <%s name='%s' file='%s'>\n" % (id.type, name, self.modulename_file(id.module))) try: (ret, params, desc) = id.info output.write(" <info>%s</info>\n" % (escape(desc))) self.indexString(name, desc) if ret[0] != None: if ret[0... | def serialize_function(self, output, name): id = self.idx.functions[name] output.write(" <%s name='%s' file='%s'>\n" % (id.type, name, self.modulename_file(id.module))) |
if glob.glob("../parser.c") != [] : | if glob.glob("parser.c") != [] : print "Rebuilding API description for libxml2" builder = docBuilder("libxml2", [".", "."], ["xmlwin32version.h", "tst.c"]) elif glob.glob("../parser.c") != [] : | def rebuild(): builder = None if glob.glob("../parser.c") != [] : print "Rebuilding API description for libxml2" builder = docBuilder("libxml2", ["..", "../include/libxml"], ["xmlwin32version.h", "tst.c", "schemasInternals.h", "xmlschemas" ]) elif glob.glob("../libxslt/transform.c") != [] : print "Rebuilding API descri... |
["xmlwin32version.h", "tst.c", "schemasInternals.h", "xmlschemas" ]) | ["xmlwin32version.h", "tst.c"]) | def rebuild(): builder = None if glob.glob("../parser.c") != [] : print "Rebuilding API description for libxml2" builder = docBuilder("libxml2", ["..", "../include/libxml"], ["xmlwin32version.h", "tst.c", "schemasInternals.h", "xmlschemas" ]) elif glob.glob("../libxslt/transform.c") != [] : print "Rebuilding API descri... |
global functions | def function(name, desc, ret, args, file): global functions functions[name] = (desc, ret, args, file) | |
wrapper.write(" | def buildStubs(): global py_types global py_return_types global unknown_types try: f = open("libxslt-api.xml") data = f.read() (parser, target) = getparser() parser.feed(data) parser.close() except IOError, msg: try: f = open("../doc/libxslt-api.xml") data = f.read() (parser, target) = getparser() parser.feed(data) ... | |
else: if idx.functions[id].static == 0: self.functions[id] = idx.functions[id] | def merge_public(self, idx): for id in idx.functions.keys(): if self.functions.has_key(id): up = idx.functions[id] self.functions[id].update(None, up.type, up.info, up.extra) else: if idx.functions[id].static == 0: self.functions[id] = idx.functions[id] | |
if found == 1: break | def buildWrappers(): global ctypes global py_types global py_return_types global unknown_types global functions global function_classes global libxml2_classes_type global classes_type global classes_list global converter_type global primary_classes global converter_type global classes_ancestor global converter_type glo... | |
output.write("libxslt_%s(ATTRIBUTE_UNUSED PyObject *self," % (name)) | output.write("libxslt_%s(PyObject *self ATTRIBUTE_UNUSED," % (name)) output.write(" PyObject *args") | def print_function_wrapper(name, output, export, include): global py_types global unknown_types global functions global skipped_modules try: (desc, ret, args, file) = functions[name] except: print "failed to get function %s infos" return if skipped_modules.has_key(file): return 0 if skip_function(name) == 1: return 0... |
output.write("ATTRIBUTE_UNUSED ") output.write(" PyObject *args) {\n") | output.write(" ATTRIBUTE_UNUSED") output.write(") {\n") | def print_function_wrapper(name, output, export, include): global py_types global unknown_types global functions global skipped_modules try: (desc, ret, args, file) = functions[name] except: print "failed to get function %s infos" return if skipped_modules.has_key(file): return 0 if skip_function(name) == 1: return 0... |
map(send, (order.volatility, order.volatility_type)) | map(send, (order.volatility, order.volatilityType)) | def place_order(self, order_id, contract, order): """ place_order(order_id, contract, order) -> place an order |
@support.restrictServerVersion(lt, 16, 'Server version mismatch.') | @support.restrictServerVersion(gt, 16, 'Server version mismatch.') | def cancelHistoricalData(self, tickerId): """ cancelHistoricalData(tickerId) -> |
start_response(self.error_status, self.error_headers[:]) | start_response(self.error_status,self.error_headers[:],sys.exc_info()) | def error_output(self, environ, start_response): """WSGI mini-app to create error output |
r"Date: \w{3} \w{3} [ 0123]\d \d\d:\d\d:\d\d \d{4}\r\n" | r"Date: \w{3}, [ 0123]\d \w{3} \d{4} \d\d:\d\d:\d\d GMT\r\n" | def non_error_app(e,s): s('200 OK',[]) return [] |
if not self.result_is_file() and not self.sendfile(): | if not self.result_is_file() or not self.sendfile(): | def finish_response(self): """Send any iterable data, then close self and the iterable |
return _build_py.get_outputs(include_bytecode) + [ | return _build_py.get_outputs(self,include_bytecode) + [ | def get_outputs(self, include_bytecode=1): |
r"Date: \w{3} \w{3} \d{2} \d\d:\d\d:\d\d \d{4}\r\n" | r"Date: \w{3} \w{3} [ 0123]\d \d\d:\d\d:\d\d \d{4}\r\n" | def non_error_app(e,s): s('200 OK',[]) return [] |
_weekdayname = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] _monthname = [None, "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] def format_date_time(timestamp): year, month, day, hh, mm, ss, wd, y, z = time.gmtime(timestamp) return "%s, %02d %3s %4d %02d:%02d:%02d GMT" % ( _wee... | def dict(items): d = {} for k,v in items: d[k] = v return d | |
'Date: %s\r\n' % time.asctime(time.gmtime(time.time())) | 'Date: %s\r\n' % format_date_time(time.time()) | def send_preamble(self): """Transmit version/status/date/server, via self._write()""" if self.origin_server: if self.client_is_modern(): self._write('HTTP/%s %s\r\n' % (self.http_version,self.status)) if not self.headers.has_key('Date'): self._write( 'Date: %s\r\n' % time.asctime(time.gmtime(time.time())) ) if self.ser... |
d2[k] = qc.get(type(v), String2literal)(v) | d2[k] = qc.get(type(v), String2Literal)(v) | def escape_dict(d, qc): d2 = {} for k,v in d.items(): d2[k] = qc.get(type(v), String2literal)(v) return d2 |
def __init__(self, connection, warnings=1): | def __init__(self, connection): | def __init__(self, connection, warnings=1): self.connection = connection self.description = None self.rowcount = -1 self.result = None self.arraysize = 100 self.warnings = warnings |
self.result = None | def __init__(self, connection, warnings=1): self.connection = connection self.description = None self.rowcount = -1 self.result = None self.arraysize = 100 self.warnings = warnings | |
self.warnings = warnings | def __init__(self, connection, warnings=1): self.connection = connection self.description = None self.rowcount = -1 self.result = None self.arraysize = 100 self.warnings = warnings | |
def _do_query(self, q): | def __do_query(self, q): | def _do_query(self, q): from string import split, atoi db = self.connection.db db.query(q) self.result = self._get_result() self.rowcount = db.affected_rows() self.description = self.result and self.result.describe() or None self._insert_id = db.insert_id() return self.rowcount |
self.result = self._get_result() | self._result = self._get_result() | def _do_query(self, q): from string import split, atoi db = self.connection.db db.query(q) self.result = self._get_result() self.rowcount = db.affected_rows() self.description = self.result and self.result.describe() or None self._insert_id = db.insert_id() return self.rowcount |
self.description = self.result and self.result.describe() or None | self.description = self._result and self._result.describe() or None | def _do_query(self, q): from string import split, atoi db = self.connection.db db.query(q) self.result = self._get_result() self.rowcount = db.affected_rows() self.description = self.result and self.result.describe() or None self._insert_id = db.insert_id() return self.rowcount |
_query = _do_query | def _check_for_warnings(self): pass _query = __do_query def info(self): try: return self._info except AttributeError: raise ProgrammingError, "execute() first" | def _do_query(self, q): from string import split, atoi db = self.connection.db db.query(q) self.result = self._get_result() self.rowcount = db.affected_rows() self.description = self.result and self.result.describe() or None self._insert_id = db.insert_id() return self.rowcount |
from string import atoi, split r = self._do_query(q) w = self.connection.db.info() if w: warnings = atoi(split(w)[-1]) if warnings: raise Warning, w return r class CursorStoreResultMixIn: def _get_result(self): return self.connection.db.store_result() def _do_query(self, q): | def _query(self, q): from string import atoi, split r = self._do_query(q) w = self.connection.db.info() if w: warnings = atoi(split(w)[-1]) if warnings: raise Warning, w return r | |
BaseCursor._do_query(self, q) self._rows = self.result and self._fetch_all_rows() or () | rowcount = self._BaseCursor__do_query(q) self._rows = self._result and self._fetch_all_rows() or () | def _do_query(self, q): self.connection._acquire() try: BaseCursor._do_query(self, q) self._rows = self.result and self._fetch_all_rows() or () self._pos = 0 del self.result finally: self.connection._release() |
del self.result | del self._result return rowcount | def _do_query(self, q): self.connection._acquire() try: BaseCursor._do_query(self, q) self._rows = self.result and self._fetch_all_rows() or () self._pos = 0 del self.result finally: self.connection._release() |
def __init__(self, name=""): BaseCursor.__init__(self, name="") | def __init__(self, connection): BaseCursor.__init__(self, connection) | def __init__(self, name=""): BaseCursor.__init__(self, name="") if not self.connection._acquire(0): raise ProgrammingError, "would deadlock" |
self.connection._release() | if self.connection: self.connection._release() | def close(self): self.connection._release() self.connection = None |
del self.result | del self._result | def __del__(self): try: del self.result finally: self.close() |
def _fetch_row(self): return self.result.fetch_row() def _fetch_rows(self, size): return self.result.fetch_rows(size) def _fetch_all_rows(self): return self.result.fetch_all_rows() | def _fetch_row(self): return self._result.fetch_row() def _fetch_rows(self, size): return self._result.fetch_rows(size) def _fetch_all_rows(self): return self._result.fetch_all_rows() | def _fetch_row(self): return self.result.fetch_row() |
def _fetch_row(self): return self.result.fetch_row_as_dict() def _fetch_rows(self, size): return self.result.fetch_rows_as_dict(size) def _fetch_all_rows(self): return self.result.fetch_all_rows_as_dict() | def _fetch_row(self): return self._result.fetch_row_as_dict() def _fetch_rows(self, size): return self._result.fetch_rows_as_dict(size) def _fetch_all_rows(self): return self._result.fetch_all_rows_as_dict() | def _fetch_row(self): return self.result.fetch_row_as_dict() |
class Cursor(CursorWarningMixIn, CursorStoreResultMixIn, CursorTupleRowsMixIn, BaseCursor): pass class DictCursor(CursorWarningMixIn, CursorStoreResultMixIn, CursorDictRowsMixIn, BaseCursor): pass class SSCursor(CursorWarningMixIn, CursorUseResultMixIn, CursorTupleRowsMixIn, BaseCursor): pass class SSDictCursor(CursorW... | class CursorNW(CursorStoreResultMixIn, CursorTupleRowsMixIn, BaseCursor): pass class Cursor(CursorWarningMixIn, CursorNW): pass class DictCursorNW(CursorStoreResultMixIn, CursorDictRowsMixIn, BaseCursor): pass class DictCursor(CursorWarningMixIn, DictCursorNW): pass class SSCursorNW(CursorUseResultMixIn, CursorTupl... | def fetchallDict(self, *args, **kwargs): return apply(self.fetchall, args, kwargs) |
self.arraysize = 100 | self.arraysize = 1 | def __init__(self, connection): self.connection = connection self.description = None self.rowcount = -1 self.arraysize = 100 self._executed = None self.lastrowid = None self.messages = [] self.errorhandler = connection.errorhandler self._result = None |
for k,v in d.items(): d2[k] = "'%s'" % escape_string(str(v)) | for k,v in d.items(): if v is None: d2[k] = "NULL" else: d2[k] = "'%s'" % escape_string(str(v)) | def escape_dict(d): d2 = {} for k,v in d.items(): d2[k] = "'%s'" % escape_string(str(v)) return d2 |
def config(what): if sys.platform == "win32": try: from win32pipe import popen except ImportError: print "win32pipe is required for building on Windows." print "Get it here: http://www.python.org/windows/win32/" raise else: | if sys.platform == "win32": mysqlroot = os.getenv('mysqlroot', None) if mysqlroot is None: print "You need to set the environment variable mysqlroot!" print "This should be the path to your MySQL installation." print "Probably C:\Program Files\MySQL 4.1\ or something like that." sys.exit(1) include_dirs = [os.path.joi... | def config(what): if sys.platform == "win32": try: from win32pipe import popen except ImportError: print "win32pipe is required for building on Windows." print "Get it here: http://www.python.org/windows/win32/" raise else: from os import popen return popen("mysql_config --%s" % what).read().strip().split() |
if sys.platform == "win32": if "zlib" not in libraries: libraries.append("zlib") else: | def config(what): if sys.platform == "win32": try: from win32pipe import popen except ImportError: print "win32pipe is required for building on Windows." print "Get it here: http://www.python.org/windows/win32/" raise else: from os import popen return popen("mysql_config --%s" % what).read().strip().split() | |
if args is None: r = self._query(query) else: r = self._query(query % self.connection.literal(args)) | r = self._query(query) | def execute(self, query, args=None): |
self._executed = query | def executemany(self, query, args): | |
from types import UnicodeType | def _do_query(self, q): from types import UnicodeType db = self._get_db() if type(q) is UnicodeType: q = q.encode(db.charset) db.query(q) self._do_get_result() return self.rowcount | |
if type(q) is UnicodeType: q = q.encode(db.charset) | self._last_executed = q | def _do_query(self, q): from types import UnicodeType db = self._get_db() if type(q) is UnicodeType: q = q.encode(db.charset) db.query(q) self._do_get_result() return self.rowcount |
td = timedelta(hours=int(h), minutes=int(m), seconds=int(s), microseconds=int(modf(float(s))[0])*1000000) | td = timedelta(hours=int(h), minutes=int(m), seconds=int(float(s)), microseconds=int(modf(float(s))[0]*1000000)) | def TimeDelta_or_None(s): from math import modf try: h, m, s = s.split(':') td = timedelta(hours=int(h), minutes=int(m), seconds=int(s), microseconds=int(modf(float(s))[0])*1000000) if h < 0: return -td else: return td except: return None |
return time(hour=int(h), minute=int(m), second=int(s), microsecond=int(modf(float(s))[0])*1000000) | return time(hour=int(h), minute=int(m), second=int(float(s)), microsecond=int(modf(float(s))[0]*1000000)) | def Time_or_None(s): from math import modf try: h, m, s = s.split(':') return time(hour=int(h), minute=int(m), second=int(s), microsecond=int(modf(float(s))[0])*1000000) except: return None |
self.rownumber = end | self.rownumber = min(end, len(self._rows)) | def fetchmany(self, size=None): """Fetch up to size rows from the cursor. Result set may be smaller than size. If size is not defined, cursor.arraysize is used.""" self._check_executed() end = self.rownumber + size or self.arraysize result = self._rows[self.rownumber:end] self.rownumber = end return result |
if r: return r[0] return None | if not r: return None self.rownumber = self.rownumber + 1 return r[0] | def fetchone(self): """Fetches a single row from the cursor.""" self._check_executed() r = self._fetch_row(1) if r: return r[0] return None |
def DateFromTicks(ticks): return apply(Date, localtime(ticks)[:3]) def TimeFromTicks(ticks): return apply(Time, localtime(ticks)[3:6]) def TimestampFromTicks(ticks): return apply(Timestamp, localtime(ticks)[:6]) | try: from DateTime import Date, Time, Timestamp, ISO def DateFromTicks(ticks): return apply(Date, localtime(ticks)[:3]) def TimeFromTicks(ticks): return apply(Time, localtime(ticks)[3:6]) def TimestampFromTicks(ticks): return apply(Timestamp, localtime(ticks)[:6]) def format_DATE(d): return d.Format("%Y-%m-%d"... | def DateFromTicks(ticks): return apply(Date, localtime(ticks)[:3]) |
def format_DATE(d): return d.Format("%Y-%m-%d") def format_TIME(d): return d.Format("%H:%M:%S") def format_TIMESTAMP(d): return d.Format("%Y-%m-%d %H:%M:%S") def mysql_timestamp_converter(s): parts = map(int, filter(None, (s[:4],s[4:6],s[6:8],s[8:10],s[10:12],s[12:14]))) return apply(Timestamp, tuple(parts))... | def format_DATE(d): return d.Format("%Y-%m-%d") | |
print q | def __do_query(self, q): from string import split, atoi db = self.connection.db print q db.query(q) self._result = self._get_result() self.rowcount = db.affected_rows() self.description = self._result and self._result.describe() or None self._insert_id = db.insert_id() self._info = db.info() self._check_for_warnings() ... | |
raise NotSupportedError, "XXX Not supported by server" | raise NotSupportedError, "Not supported by server" | def rollback(self): """Rollback the current transaction.""" if self._transactional: self._db.query("ROLLBACK") else: raise NotSupportedError, "XXX Not supported by server" |
library_dirs = [ i[2:] for i in libs if i.startswith("-L") ] libraries = [ i[2:] for i in libs if i.startswith("-l") ] | library_dirs = [ stripquotes(i[2:]) for i in libs if i.startswith("-L") ] libraries = [ stripquotes(i[2:]) for i in libs if i.startswith("-l") ] | def config(what): from os import popen f = popen("mysql_config --%s" % what) data = f.read().strip().split() if f.close(): data = [] return data |
print "Alas! I die!" | def __del__(self): if hasattr(self, '_db'): self.close() print "Alas! I die!" | |
def callproc(self, procname, *args): | def callproc(self, procname, args): | def callproc(self, procname, *args): |
from types import UnicodeType | def callproc(self, procname, *args): | |
db.query("SET @_%s_%d=%s" % (procname, index, db.literal(arg))) | q = "SET @_%s_%d=%s" % (procname, index, db.literal(arg)) if type(q) is UnicodeType: q = q.encode(db.charset) db.query(q) self._do_get_result() | def callproc(self, procname, *args): |
result = self.rownumber and self._rows[self.rownumber:] or self._rows | if self.rownumber: result = self._rows[self.rownumber:] else: result = self._rows | def fetchall(self): """Fetchs all available rows from the cursor.""" self._check_executed() result = self.rownumber and self._rows[self.rownumber:] or self._rows self.rownumber = len(self._rows) return result |
libs = mysql_config("libmysqld_libs") | libs = mysql_config("libmysqld-libs") | def enabled(option): value = options[option] s = value.lower() if s in ('yes','true','1','y'): return True elif s in ('no', 'false', '0', 'n'): return False else: raise Abort, "Unknown value %s for option %s" % (value, option) |
if kwargs['db'][0] in ('+', '-'): | if kwargs['db'] and kwargs['db'][0] in ('+', '-'): | def _parse_connection_string(self, connection): kwargs = {'conv': self.conv} items = split(connection) if not items: return kwargs db_host, items = items[0], items[1:] if '@' in db_host: db, host = split(db_host,'@',1) kwargs['db'] = db if ':' in host: host, port = split(host,':',1) kwargs['port'] = int(port) kwargs['h... |
return apply(datetime, tuple(d.split('-')+t.split(':'))) | return apply(datetime, tuple(map(int, d.split('-')+t.split(':')))) | def DateTime_or_None(s): if ' ' in s: sep = ' ' elif 'T' in s: sep = 'T' else: return None try: d, t = s.split(sep, 1) return apply(datetime, tuple(d.split('-')+t.split(':'))) except: return None |
try: from mx import DateTime except ImportError: import DateTime from DateTime import Date, Time, Timestamp, ISO, \ DateTimeType, DateTimeDeltaType | try: from mx import DateTime from mx.DateTime import Date, Time, Timestamp, ISO, \ DateTimeType, DateTimeDeltaType except ImportError: import DateTime from DateTime import Date, Time, Timestamp, ISO, \ DateTimeType, DateTimeDeltaType | def Thing2Literal(o, d={}): return string_literal(str(o)) |
format_TIME = format_TIMESTAMP = format_DATE = \ TimeDelta_or_None = Date_or_None | format_TIME = format_TIMESTAMP = format_DATE TimeDelta_or_None = Date_or_None = DateTime_or_None = format_DATE | def format_DATE(d): """Format a date as a date (does nothing, you don't have mx.DateTime).""" return d |
end = self.rownumber + size or self.arraysize | end = self.rownumber + (size or self.arraysize) | def fetchmany(self, size=None): """Fetch up to size rows from the cursor. Result set may be smaller than size. If size is not defined, cursor.arraysize is used.""" self._check_executed() end = self.rownumber + size or self.arraysize result = self._rows[self.rownumber:end] self.rownumber = min(end, len(self._rows)) retu... |
library_dirs = [ dequote(i[2:]) for i in libs if i.startswith("-L") ] libraries = [ dequote(i[2:]) for i in libs if i.startswith("-l") ] | library_dirs = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("L")) ] libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ] | def enabled(option): value = options[option] s = value.lower() if s in ('yes','true','1','y'): return True elif s in ('no', 'false', '0', 'n'): return False else: raise Abort, "Unknown value %s for option %s" % (value, option) |
removable_compile_args = '-I -L -l'.split() | removable_compile_args = [ compiler_flag(f) for f in "ILl" ] | def enabled(option): value = options[option] s = value.lower() if s in ('yes','true','1','y'): return True elif s in ('no', 'false', '0', 'n'): return False else: raise Abort, "Unknown value %s for option %s" % (value, option) |
if i.startswith('-I') ] | if i.startswith(compiler_flag('I')) ] | def enabled(option): value = options[option] s = value.lower() if s in ('yes','true','1','y'): return True elif s in ('no', 'false', '0', 'n'): return False else: raise Abort, "Unknown value %s for option %s" % (value, option) |
extra_compile_args.append("-Dversion_info=\"%s\"" % metadata['version_info']) extra_compile_args.append("-D__version__=\"%s\"" % metadata['version']) | extra_compile_args.append(compiler_flag("Dversion_info=%s" % metadata['version_info'])) extra_compile_args.append(compiler_flag("D__version__=%s" % metadata['version'])) | def enabled(option): value = options[option] s = value.lower() if s in ('yes','true','1','y'): return True elif s in ('no', 'false', '0', 'n'): return False else: raise Abort, "Unknown value %s for option %s" % (value, option) |
def _fetchall(result, *args): rows = r = list(apply(result.fetch_row, args)) while 1: rows = list(apply(result.fetch_row, args)) if not rows: break r.extend(list(rows)) return r | def escape_dict(d, qc): d2 = {} for k,v in d.items(): d2[k] = qc.get(type(v), String2Literal)(v) return d2 | |
except TypeError, m: if m.args[0] in ("not enough arguments for format string", | except TypeError, msg: if msg.args[0] in ("not enough arguments for format string", | def executemany(self, query, args): """cursor.executemany(self, query, args) query -- string, query to execute on server args -- sequence of sequences or mappings, parameters to use with query. The query must contain the clause "values ( ... )". The parenthetical portion will be repeated once for each item in the sequ... |
raise ProgrammingError, m.args[0] | raise ProgrammingError, msg.args[0] | def executemany(self, query, args): """cursor.executemany(self, query, args) query -- string, query to execute on server args -- sequence of sequences or mappings, parameters to use with query. The query must contain the clause "values ( ... )". The parenthetical portion will be repeated once for each item in the sequ... |
def _fetch_row(self): return self._result.fetch(1)[0] def _fetch_rows(self, size): return self._result.fetch(size) def _fetch_all_rows(self): r = list(self._result.fetch(self.arraysize)) while len(r) >= self.arraysize: rows = self._result.fetch(self.arraysize) if not rows: break r.extend(list(rows)) return r | def _fetch_row(self): return self._result.fetch_row(1)[0] def _fetch_rows(self, size): return self._result.fetch_row(size) def _fetch_all_rows(self): return _fetchall(self._result, self.arraysize) | def _fetch_row(self): return self._result.fetch(1)[0] |
def _fetch_all_rows(self): r = list(self._result.fetch(self.arraysize, 1)) while len(r) >= self.arraysize: rows = self._result.fetch(self.arraysize, 1) if not rows: break r.extend(list(rows)) return r | def _fetch_all_rows(self): return _fetchall(self._result, self.arraysize, 1) | def _fetch_all_rows(self): r = list(self._result.fetch(self.arraysize, 1)) while len(r) >= self.arraysize: rows = self._result.fetch(self.arraysize, 1) if not rows: break r.extend(list(rows)) return r |
def list_dbs(self): return self.db.list_dbs().fetch_all_rows() def list_fields(self, table): return self.db.list_fields(table).fetch_all_rows() def list_processes(self): return self.db.list_processes().fetch_all_rows() def list_tables(self, db): return self.db.list_tables(db).fetch_all_rows() | def list_dbs(self): return _fetchall(self.db.list_dbs()) def list_fields(self, table): return _fetchall(self.db.list_fields(table)) def list_processes(self): return _fetchall(self.db.list_processes()) def list_tables(self, db): return _fetchall(self.db.list_tables(db)) | def list_dbs(self): return self.db.list_dbs().fetch_all_rows() |
if self.result: self.description = self.result.describe() self.rowcount = db.affected_rows() else: self.description = None self.rowcount = -1 | self.rowcount = db.affected_rows() self.description = self.result and self.result.describe() or None | def _query(self, q): from string import split, atoi db = self.connection.db db.query(q) if self.use: self.result = db.use_result() else: self.result = db.store_result() |
and isinstance(o, x), d.keys()) | and isinstance(o, x) and d[x] is not Instance2Str, d.keys()) | def Instance2Str(o, d): """ Convert an Instance to a string representation. If the __str__() method produces acceptable output, then you don't need to add the class to conversions; it will be handled by the default converter. If the exact class is not found in d, it will use the first class it can find for which o i... |
def DATE(d): return d.Format("%Y-%m-%d") def TIME(d): return d.Format("%H:%M:%S") def TIMESTAMP(d): return d.Format("%Y-%m-%d %H:%M:%S") | def format_DATE(d): return d.Format("%Y-%m-%d") def format_TIME(d): return d.Format("%H:%M:%S") def format_TIMESTAMP(d): return d.Format("%Y-%m-%d %H:%M:%S") | def DATE(d): return d.Format("%Y-%m-%d") |
def setinputsizes(self, size): pass | def setinputsizes(self, *args): pass | def setinputsizes(self, size): pass |
def setoutputsizes(self, size): pass | def setoutputsizes(self, *args): pass | def setoutputsizes(self, size): pass |
from types import TupleType | from types import ListType, TupleType | def execute(self, query, args=None): from types import TupleType from string import rfind, join, split, atoi if not args: self._query(query) elif type(args) is TupleType: self._query(query % escape_row(args)) else: self.executemany(query, args) # deprecated |
elif type(args) is TupleType: self._query(query % escape_row(args)) else: self.executemany(query, args) | elif type(args) is ListType and type(args[0]) is TupleType: self.executemany(query, args) else: try: self._query(query % escape_row(args)) except TypeError: self._query(query % escape_dict(args)) | def execute(self, query, args=None): from types import TupleType from string import rfind, join, split, atoi if not args: self._query(query) elif type(args) is TupleType: self._query(query % escape_row(args)) else: self.executemany(query, args) # deprecated |
from string import rfind, join p = rfind(query, '(') if p == -1: raise ProgrammingError, "can't find values" | from string import join m = insert_values(query) if not m: raise ProgrammingError, "can't find values" p = m.start(1) | def executemany(self, query, args=None): from string import rfind, join p = rfind(query, '(') if p == -1: raise ProgrammingError, "can't find values" n = len(args)-1 q = [query % escape_row(args[0])] qv = query[p:] for a in args[1:]: q.append(qv % escape_row(a)) self._query(join(q, ',\n')) |
q = [query % escape_row(args[0])] | escape = escape_row try: q = [query % escape(args[0])] except TypeError: escape = escape_dict q = [query % escape(args[0])] | def executemany(self, query, args=None): from string import rfind, join p = rfind(query, '(') if p == -1: raise ProgrammingError, "can't find values" n = len(args)-1 q = [query % escape_row(args[0])] qv = query[p:] for a in args[1:]: q.append(qv % escape_row(a)) self._query(join(q, ',\n')) |
for a in args[1:]: q.append(qv % escape_row(a)) | for a in args[1:]: q.append(qv % escape(a)) | def executemany(self, query, args=None): from string import rfind, join p = rfind(query, '(') if p == -1: raise ProgrammingError, "can't find values" n = len(args)-1 q = [query % escape_row(args[0])] qv = query[p:] for a in args[1:]: q.append(qv % escape_row(a)) self._query(join(q, ',\n')) |
def nextset(self): pass | def nextset(self): return None | def nextset(self): pass |
def __init__(self, dsn=None, user=None, password=None, host=None, database=None, **kwargs): newargs = {} if user: newargs['user'] = user if password: newargs['passwd'] = password if host: newargs['host'] = host if database: newargs['db'] = database newargs.update(kwargs) self.db = apply(_mysql.connect, (), newargs) | def __init__(self, **kwargs): self.db = apply(_mysql.connect, (), kwargs) | def __init__(self, dsn=None, user=None, password=None, host=None, database=None, **kwargs): newargs = {} if user: newargs['user'] = user if password: newargs['passwd'] = password if host: newargs['host'] = host if database: newargs['db'] = database newargs.update(kwargs) self.db = apply(_mysql.connect, (), newargs) |
conv[FIELD_TYPE.STRING] = unicode conv[FIELD_TYPE.VAR_STRING] = unicode conv[FIELD_TYPE.BLOB].insert(-1, (None, unicode)) self.converter[types.StringType] = self.string_literal self.converter[types.UnicodeType] = self.unicode_literal | def u(s, self=proxy(self)): return s.decode(self.charset) conv[FIELD_TYPE.STRING] = u conv[FIELD_TYPE.VAR_STRING] = u conv[FIELD_TYPE.BLOB].insert(-1, (None, u)) def string_literal(obj, dummy=None, self=proxy(self)): return self.string_literal(obj) def unicode_literal(u, dummy=None, self=proxy(self)): return self.lit... | def __init__(self, *args, **kwargs): """ |
def unicode_literal(self, u, dummy=None): """ Convert a unicode object u to a string using the current character set as the encoding. If that's not available, latin1 is used. Non-standard. For internal use; do not use this in your applications. """ return self.literal(u.encode(self.charset)) | def literal(self, o): """ | |
self.__conn.query("SHOW VARIABLES") self.__vars = {} for k, v in self.__conn.store_result().fetch_row(0): self.__vars[k] = v | self.__transactional = self.__conn.server_capabilities & CLIENT.TRANSACTIONS | def __init__(self, host, user, passwd, db): kwargs = {} kwargs['conv'] = _type_conv if host: kwargs['host'] = host if user: kwargs['user'] = user if passwd: kwargs['passwd'] = passwd if db: kwargs['db'] = db try: self.__conn = apply(MySQL.connect, (), kwargs) except MySQL.Error, msg: raise error, msg self.__curs = Curs... |
if self.__vars.get('have_bdb', 'NO') == 'YES': | if self.__transactional: | def commit(self): """Commit the current transaction.""" if self.__vars.get('have_bdb', 'NO') == 'YES': self.__conn.query("COMMIT") |
if self.__vars.get('have_bdb', 'NO') == 'YES': | if self.__transactional: | def rollback(self): """Rollback the current transaction.""" if self.__vars.get('have_bdb', 'NO') == 'YES': self.__conn.query("ROLLBACK") else: raise error, "Not supported by server" |
conv={ FIELD_TYPE.TIMESTAMP: _mysql_timestamp_converter, FIELD_TYPE.TINY: int, FIELD_TYPE.SHORT: int, FIELD_TYPE.LONG: long, FIELD_TYPE.FLOAT: float, FIELD_TYPE.DOUBLE: float, FIELD_TYPE.LONGLONG: long, FIELD_TYPE.INT24: int, FIELD_TYPE.YEAR: int, FIELD_TYPE.DATETIME: DateTime_or_None, FIELD_TYPE.DATE: DateTime_or_None... | conv=conversions.copy() conv[FIELD_TYPE.DATETIME] = DateTime_or_None conv[FIELD_TYPE.DATE] = DateTime_or_None del conv[FIELD_TYPE.TIME] | def DateTime_or_None(s): try: return DateTime(s) except: return None |
if leak_test: def tearDown(self): | def tearDown(self): if self.leak_test: | def setUp(self): import gc db = self.db_module.connect(*self.connect_args, **self.connect_kwargs) self.connection = db self.cursor = db.cursor() self.BLOBText = ''.join([chr(i) for i in range(256)] * 100); self.BLOBUText = u''.join([unichr(i) for i in range(16384)]) self.BLOBBinary = self.db_module.Binary(''.join([chr(... |
def next(self): """Fetches the next row. StopIteration is raised when there are no more rows, if Python has iterator support. Otherwise, IndexError is raised.""" result = self.fetchone() if result is None: raise _EndOfData return result def __iter__(self): return self | def __iter__(self): return iter(self.fetchone, None) | def next(self): """Fetches the next row. StopIteration is raised when there are no more rows, if Python has iterator support. Otherwise, IndexError is raised.""" result = self.fetchone() if result is None: raise _EndOfData return result |
def __iter__(self): self._check_executed() result = self.rownumber and self._rows[self.rownumber:] or self._rows return iter(result) | def scroll(self, value, mode='relative'): """Scroll the cursor in the result set to a new position according to mode. If mode is 'relative' (default), value is taken as offset to the current position in the result set, if set to 'absolute', value states an absolute target position.""" self._check_executed() if mode ==... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.