All Samples(283764) | Call(281404) | Derive(2357) | Import(3)
str(object) -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object.
src/q/u/quickflash-HEAD/rtflame/examples/flame_slicer/metadata_reader.py quickflash(Download)
def get_string(self, line_prefix="") :
string = line_prefix + "Name [ " + str(self.__name) + " ]\n"
if (self.__type is not None) :
string += line_prefix + " Type [ " + str(self.__type) + " ]\n"
string += line_prefix + " Sort key [ " + str(self.__sort_key) + " ]\n"
for key in self.__values :
string += line_prefix + " Key [ " + str(key) + " ] Value [ " \
+ str(self.__values[key]) + " ]\n"
src/b/e/beatbox-20.0/examples/soql2atom.py beatbox(Download)
def soql2atom(loginResult, soql, title): soqlWithFields = addRequiredFieldsToSoql(soql) userInfo = loginResult[beatbox._tPartnerNS.userInfo] serverUrl = str(loginResult[beatbox._tPartnerNS.serverUrl]) (scheme, host, path, params, query, frag) = urlparse(serverUrl)
x.characters("\n")
x.startElement(atom_ns, "author")
x.writeStringElement(atom_ns, "name", str(userInfo.userFullName))
x.endElement()
x.characters("\n")
x.endElement()
x.writeStringElement(atom_ns, "updated", datetime.datetime.utcnow().isoformat() +"Z")
x.writeStringElement(atom_ns, "id", thisUrl + "&userid=" + str(loginResult[beatbox._tPartnerNS.userId]))
x.characters("\n")
type = AttributesNSImpl({(None, u"type") : "html"}, {(None, u"type") : u"type" })
for row in qr[sf.records:]:
x.startElement(atom_ns, "entry")
desc = ""
x.writeStringElement(atom_ns, "title", str(row[2]))
for col in row[2:]: if col._name[1] == 'Id': x.writeStringElement(atom_ns, "id", sfbaseUrl + str(col)) writeLink(x, atom_ns, "link", "alternate", "text/html", sfbaseUrl + str(col)) elif col._name[1] == 'SystemModstamp':
src/p/y/python-oauth-HEAD/oauth/example/server.py python-oauth(Download)
self.access_token = oauth.OAuthToken('accesskey', 'accesssecret')
self.nonce = 'nonce'
self.verifier = VERIFIER
def lookup_consumer(self, key):
def lookup_token(self, token_type, token):
token_attrib = getattr(self, '%s_token' % token_type)
if token == token_attrib.key:
## HACK
token_attrib.set_callback(CALLBACK_URL)
def send_oauth_error(self, err=None):
# send a 401 error
self.send_error(401, str(err.message))
# return the authenticate header
header = oauth.build_authenticate_header(realm=REALM)
# request token
if self.path.startswith(REQUEST_TOKEN_URL):
try:
# create a request token
# user authorization
if self.path.startswith(AUTHORIZATION_URL):
try:
# get the request token
src/q/u/quickflash-HEAD/trunk/examples/omega_analysis/composite.py quickflash(Download)
header_text_string = self.__main_title \
+ " - Time " + str(self.__time)
header_subtext_string = "Envelope x-range " \
+ str(self.__min_envelope_pos) + " - " \
+ str(self.__max_envelope_pos)
dataset_desc_text_string = "Dataset Min Value [ " \
+ str(dataset_min_value) \
+ " ] Max Value [ " \
+ str(dataset_max_value) \
src/b/a/badger-lib-HEAD/packages/oauth/oauth/example/client.py badger-lib(Download)
def access_resource(self, oauth_request):
# via post body
# -> some protected resources
headers = {'Content-Type' :'application/x-www-form-urlencoded'}
self.connection.request('POST', RESOURCE_URL, body=oauth_request.to_postdata(), headers=headers)
def run_example():
# setup
print '** OAuth Python Library Example **'
client = SimpleOAuthClient(SERVER, PORT, REQUEST_TOKEN_URL, ACCESS_TOKEN_URL, AUTHORIZATION_URL)
src/p/a/parallel-python-example-HEAD/testLogin.py parallel-python-example(Download)
self.assertEqual("Login - Sauce Labs", sel.get_title())
try: self.assertEqual("Incorrect username or password", sel.get_text("css=.error-box"))
except AssertionError, e: self.verificationErrors.append(str(e))
try: self.failUnless(sel.is_element_present("css=.login input[name=username]"))
except AssertionError, e: self.verificationErrors.append(str(e))
try: self.failUnless(sel.is_element_present("css=.login input[name=password][type=password]"))
except AssertionError, e: self.verificationErrors.append(str(e))
try: self.failUnless(sel.is_element_present("css=.login input[name=submit][type=submit]"))
except AssertionError, e: self.verificationErrors.append(str(e))
self.assertEqual("Login - Sauce Labs", sel.get_title())
try: self.assertEqual("Incorrect username or password", sel.get_text("css=.error-box"))
except AssertionError, e: self.verificationErrors.append(str(e))
try: self.failUnless(sel.is_element_present("css=.login input[name=username]"))
except AssertionError, e: self.verificationErrors.append(str(e))
src/s/h/shedskin-HEAD/examples/pylife_main.py shedskin(Download)
def showmem(self):
self.screen.addstr(0, 0, str(self.steps) + self.board.info())
def showcursor(self):
self.screen.move(self.cury - self.offsety, self.curx - self.offsetx)
src/p/e/pexpect-u-2.5.1/examples/rippy.py pexpect-u(Download)
if options['video_bitrate']=='calc':
options['video_bitrate'] = options['video_bitrate_overhead'] * apply_smart (calc_video_bitrate, options)
print "# video bitrate : " + str(options['video_bitrate'])
if options['video_crop_area']=='detect':
options['video_crop_area'] = apply_smart (crop_detect, options)
print "# crop area : " + str(options['video_crop_area'])
print command_output
print "parsed command_output:"
print str(idl)
return -1
return float(idl[0])
seek_filter = ''
if seek_skip is not None:
seek_filter = '-ss %s' % (str(seek_skip))
if seek_length is not None:
seek_filter = seek_filter + ' -endpos %s' % (str(seek_length))
src/p/y/PyAMF-0.6.1/doc/tutorials/examples/actionscript/guestbook/python/guestbook.py PyAMF(Download)
def is_valid_email(email):
"""
A very basic email address format validator
"""
if re.match(EMAIL_RE, email) != None:
if not isinstance(name, basestring):
name = str(name)
if len(name) > 50:
raise IOError, "Name exceeds maximum length (50 chars max)"
if not isinstance(url, basestring):
url = str(url)
if not isinstance(email, basestring):
email = str(email)
if not is_valid_email(email):
raise ValueError, "Email address is not valid"
if not isinstance(message, basestring):
message = str(message)
src/g/1/g15m-HEAD/trunk/lglcd/Examples/PyNetstat.py g15m(Download)
# call once to get dwSize
ctypes.windll.iphlpapi.GetTcpTable(NULL, ctypes.byref(dwSize), bOrder)
# ANY_SIZE is used out of convention (to be like MS docs); even setting this
# only record TCP ports where we're listening on our external
# (or all) connections
if str(lAddr) != "127.0.0.1" and portState == MIB_TCP_STATE_LISTEN:
portList.append(str(lPort) + "/TCP")
# call once to get dwSize
ctypes.windll.iphlpapi.GetUdpTable(NULL, ctypes.byref(dwSize), bOrder)
ANY_SIZE = dwSize.value # again, used out of convention
# only record UDP ports where we're listening on our external
# (or all) connections
if str(lAddr) != "127.0.0.1":
portList.append(str(lPort) + "/UDP")
else:
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next