All Samples(195712) | Call(195207) | Derive(505) | Import(0)
int(x[, base]) -> integer Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. If base is zero, the proper base is guessed based on the string content. If the argument is outside the integer range a long object will be returned instead.
src/s/h/shedskin-HEAD/examples/msp_ss.py shedskin(Download)
def __init__(self, aTimeout=-1, aProlongFactor=-1): # shed skin : change default None arguments
"""init bsl object, don't connect yet"""
if aTimeout == -1: #is None:
self.timeout = DEFAULT_TIMEOUT
else:
self.timeout = aTimeout
if aProlongFactor == -1: #is None:
self.prolongFactor = DEFAULT_PROLONG
self.telosI2C = 0
self.protocolMode = MODE_BSL
self.BSLMemAccessWarning = 0 #Default: no warning.
self.slowmode = 0
plenty of time to the micro controller to finish the command.
Returns zero if the function is successful."""
if DEBUG > 1: sys.stderr.write("* comInit()\n")
self.seqNo = 0
self.reqNo = 0
used in other programs.
Returns zero if the function is successful."""
if DEBUG > 1: sys.stderr.write("* comDone()")
self.SetRSTpin(1) #disable power
self.SetTESTpin(0) #disable power
src/b/i/bitey-0.0/examples/mandel/png.py bitey(Download)
"palette entry %d: all 4-tuples must precede all 3-tuples" % i)
for x in t:
if int(x) != x or not(0 <= x <= 255):
raise ValueError(
"palette entry %d: values must be integer: 0 <= x <= 255" % i)
def isinteger(x):
try:
return int(x) == x
except:
return False
raise ValueError(
"bytes per sample must be .125, .25, .5, 1, or 2")
bitdepth = int(8*bytes_per_sample)
del bytes_per_sample
if not isinteger(bitdepth) or bitdepth < 1 or 16 < bitdepth:
self.alpha = bool(alpha)
self.colormap = bool(palette)
self.bitdepth = int(bitdepth)
self.compression = compression
self.chunk_limit = chunk_limit
if self.gamma is not None:
write_chunk(outfile, 'gAMA',
struct.pack("!L", int(round(self.gamma*1e5))))
# See :chunk:order
src/p/y/py_examples-HEAD/phonon/kakawana-read-only/src/kakawana/feedparser.py py_examples(Download)
codepoint2name={}
for (name,codepoint) in htmlentitydefs.entitydefs.iteritems():
if codepoint.startswith('&#'): codepoint=unichr(int(codepoint[2:-1]))
name2codepoint[name]=ord(codepoint)
codepoint2name[ord(codepoint)]=name
else:
if ref[0] == 'x':
c = int(ref[1:], 16)
else:
c = int(ref)
is_htmlish = self.mapContentType(self.contentparams.get('type', 'text/html')) in self.html_types
# resolve relative URIs within embedded markup
if is_htmlish and RESOLVE_RELATIVE_URIS:
if element in self.can_contain_relative_uris:
output = _resolveRelativeURIs(output, self.baseuri, self.encoding, self.contentparams.get('type', 'text/html'))
# sanitize embedded markup
if is_htmlish and SANITIZE_HTML:
if element in self.can_contain_dangerous_markup:
output = _sanitizeHTML(output, self.encoding, self.contentparams.get('type', 'text/html'))
src/g/a/gaesdk-python-HEAD/lib/PyAMF/doc/tutorials/examples/gateways/appengine/demo/simplejson/decoder.py gaesdk-python(Download)
if len(esc) != 4:
raise ValueError
uni = int(esc, 16)
if 0xd800 <= uni <= 0xdbff and sys.maxunicode > 65535:
msg = "Invalid \\uXXXX\\uXXXX surrogate pair"
if len(esc2) != 4:
raise ValueError
uni2 = int(esc2, 16)
uni = 0x10000 + (((uni - 0xd800) << 10) | (uni2 - 0xdc00))
next_end += 6
src/p/o/pony-build-HEAD/examples/push-cgi-notifier/feedparser.py pony-build(Download)
else:
if ref[0] == 'x':
c = int(ref[1:], 16)
else:
c = int(ref)
k = htmlentitydefs.entitydefs[k]
if k.startswith('&#') and k.endswith(';'):
return int(k[2:-1]) # not in latin-1
return ord(k)
try: name2cp(ref)
def _end_width(self):
value = self.pop('width')
try:
value = int(value)
except:
def _end_height(self):
value = self.pop('height')
try:
value = int(value)
except:
src/b/a/badger-lib-HEAD/packages/pyparsing/docs/examples/sexpParser.py badger-lib(Download)
LPAR, RPAR, LBRK, RBRK, LBRC, RBRC, VBAR = map(Suppress, "()[]{}|")
decimal = Word("123456789",nums).setParseAction(lambda t: int(t[0]))
bytes = Word(printables)
raw = Group(decimal.setResultsName("len") + Suppress(":") + bytes).setParseAction(verifyLen)
hexadecimal = ("#" + OneOrMore(Word(hexnums)) + "#")\
.setParseAction(lambda t: int("".join(t[1:-1]),16))
qString = Group(Optional(decimal,default=None).setResultsName("len") +
dblQuotedString.setParseAction(removeQuotes)).setParseAction(verifyLen)
src/b/a/badger-lib-HEAD/packages/pyparsing/examples/sexpParser.py badger-lib(Download)
LPAR, RPAR, LBRK, RBRK, LBRC, RBRC, VBAR = map(Suppress, "()[]{}|")
decimal = Word("123456789",nums).setParseAction(lambda t: int(t[0]))
bytes = Word(printables)
raw = Group(decimal.setResultsName("len") + Suppress(":") + bytes).setParseAction(verifyLen)
hexadecimal = ("#" + OneOrMore(Word(hexnums)) + "#")\
.setParseAction(lambda t: int("".join(t[1:-1]),16))
qString = Group(Optional(decimal,default=None).setResultsName("len") +
dblQuotedString.setParseAction(removeQuotes)).setParseAction(verifyLen)
src/w/i/winappdbg-1.4/examples/instrumentation/05_read_memory.py winappdbg(Download)
if __name__ == "__main__":
import sys
pid = int( sys.argv[1] )
address = int( sys.argv[2], 0x10 )
length = int( sys.argv[3] )
src/p/r/processing.py-HEAD/examples.py/Python/colornames/namethatcolor/NameThatColor.py processing.py(Download)
def rgb(self, color):
"""Given a hex string representing a color, return an object with
values representing red, green, and blue.
"""
return RGB(int(color[1:3], 16),
int(color[3:5], 16),
int(color[5:7], 16))
hue /= 6
return HSL(int(hue * 255),
int(saturation * 255),
int(lightness * 255))
src/p/y/PyAMF-0.6.1/doc/tutorials/examples/gateways/appengine/demo/simplejson/decoder.py PyAMF(Download)
if len(esc) != 4:
raise ValueError
uni = int(esc, 16)
if 0xd800 <= uni <= 0xdbff and sys.maxunicode > 65535:
msg = "Invalid \\uXXXX\\uXXXX surrogate pair"
if len(esc2) != 4:
raise ValueError
uni2 = int(esc2, 16)
uni = 0x10000 + (((uni - 0xd800) << 10) | (uni2 - 0xdc00))
next_end += 6
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next