當前位置: 首頁>>代碼示例>>Python>>正文


Python idlelib.PyShell類代碼示例

本文整理匯總了Python中idlelib.PyShell的典型用法代碼示例。如果您正苦於以下問題:Python PyShell類的具體用法?Python PyShell怎麽用?Python PyShell使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PyShell類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setUpClass

 def setUpClass(cls):
     cls.root = root = tk.Tk()
     PyShell.fix_x11_paste(root)
     cls.text = tk.Text(root)
     cls.entry = tk.Entry(root)
     cls.spin = tk.Spinbox(root)
     root.clipboard_clear()
     root.clipboard_append('two')
開發者ID:Logotrop,項目名稱:trida,代碼行數:8,代碼來源:test_editmenu.py

示例2: idle_showwarning_subproc

def idle_showwarning_subproc(message, category, filename, lineno, file=None, line=None):
    """Show Idle-format warning after replacing warnings.showwarning.

    The only difference is the formatter called.
    """
    if file is None:
        file = sys.stderr
    try:
        file.write(PyShell.idle_formatwarning(message, category, filename, lineno, line))
    except IOError:
        pass  # the file (probably stderr) is invalid - this warning gets lost.
開發者ID:van7hu,項目名稱:fanca,代碼行數:11,代碼來源:run.py

示例3: print

    def 開窗來跑(我):
        '''
        目前隻準跑 翻譯後的 中文程式,
        並讓人隨意修改之,
        
        原版英文程式不準改,
        因為那是係統的一部份。
        
        本功能基本上可跑,
        但在「關」窗時,
        會出現一些 「髒」,
        仍待改。
        '''
      
        import sys

        '''
        import idlelib
        from idlelib import PyShell       
        PyShell= importlib.reload(idlelib.PyShell)
        '''
        #import idlelib.ryPyShell as PyShell
        import idlelib.PyShell as PyShell

        fn= 我.module.__file__
        
        #print('fn= ', fn)
        tcDir= 我.tcDir #= 'tcDir'
        if os.path.abspath(os.path.dirname(fn)) != os.path.abspath(tcDir):
            msg=  '%s not in %s\n'%(fn, os.path.abspath(tcDir))
            msg+= '目前隻準跑 翻譯後的 中文程式,並隨意修改之。\n'
            print(msg)
            return
            
        sys.argv= ['', '-r', fn]

        #我.root.wm_protocol("WM_DELETE_WINDOW", 我._destroy)

 
        PyShell.main() #### 這行 在 windows 上 OK; 但 mac 不 OK !!!!
開發者ID:renyuanL,項目名稱:tcTranslate2016,代碼行數:40,代碼來源:ryViewer2.py

示例4:

#!/usr/bin/python

try:
    import idlelib.PyShell
except ImportError:
    # IDLE is not installed, but maybe PyShell is on sys.path:
    try:
        import PyShell
    except ImportError:
        raise
    else:
        import os
        idledir = os.path.dirname(os.path.abspath(PyShell.__file__))
        if idledir != os.getcwd():
            # We're not in the IDLE directory, help the subprocess find run.py
            pypath = os.environ.get('PYTHONPATH', '')
            if pypath:
                os.environ['PYTHONPATH'] = pypath + ':' + idledir
            else:
                os.environ['PYTHONPATH'] = idledir
        PyShell.main()
else:
    idlelib.PyShell.main()
開發者ID:Lamouse,項目名稱:Evolutionary-Creativity,代碼行數:23,代碼來源:idle.py

示例5: test_shell_show

 def test_shell_show(self):
     with captured_stderr() as f:
         shell.idle_showwarning(
                 'Test', UserWarning, 'test_warning.py', 99, f, 'Line of code')
         self.assertEqual(shellmsg.splitlines(), f.getvalue().splitlines())
開發者ID:AtomicConductor,項目名稱:conductor_client,代碼行數:5,代碼來源:test_warning.py

示例6: test_idle_formatter

 def test_idle_formatter(self):
     # Will fail if format changed without regenerating idlemsg
     s = shell.idle_formatwarning(
             'Test', UserWarning, 'test_warning.py', 99, 'Line of code')
     self.assertEqual(idlemsg, s)
開發者ID:AtomicConductor,項目名稱:conductor_client,代碼行數:5,代碼來源:test_warning.py

示例7: test_showwarnings

 def test_showwarnings(self):
     self.assertIs(warnings.showwarning, showwarning)
     shell.capture_warnings(True)
     self.assertIs(warnings.showwarning, shell.idle_showwarning)
     shell.capture_warnings(False)
     self.assertIs(warnings.showwarning, showwarning)
開發者ID:AtomicConductor,項目名稱:conductor_client,代碼行數:6,代碼來源:test_warning.py

示例8: crawl

def crawl():
	global lis,bis,data1,data2,url,ratings,reviews,driver
	for uri in start_url:
		url_q.enqueue(uri.strip())
	driver,wait=define_driver()
	print "\n*****************Starting the CRAWL*********************************\n"
	while not url_q.isEmpty():
		url=url_q.dequeue()
		##Going to the Reviews Part of the page
		driver=driver_get(driver,url+'#reviews')

		print "\n************Waiting for the reviews page to load***********\n"
		while True:
			try:
				wait.until(EC.presence_of_element_located((By.CSS_SELECTOR,'#reviews > div.s-title.mbot0.borderless')))
				break
			except:
				print "......Network Error....."
		print "\n************Reviews Page LOADED********************\n"


		##getting the user_id
		print "\n***************Fetching the user_ID********************\n"
		try:
			user_id=driver.find_element_by_xpath('//div[contains(@class,"follow")]').get_attribute('data-user-id')
		except:
			user_id=-1

		try:
			no_of_reviews=driver.find_element_by_xpath('//a[@data-tab="reviews"]').text
			no_of_reviews = re.findall('\d+',no_of_reviews)
			no_of_reviews = int(no_of_reviews[0])
		except:
			no_of_reviews=0

		if user_id in users_crawled or user_id==-1:
			print "\n__________User already CRAWLED________________\n"
			continue

		try:
			if driver.find_element_by_xpath('//div[contains(@class,"usr-location")]').text.strip()!='Kolkata':
				continue
		except:
			pass
		if no_of_reviews!=0:
			print "\n__________________New USER... Starting the crawl__________________\n"

			#Getting and Clicking the LOAD MORE button
			print "\n**********Clicking the LOAD_MORE button***********\n"
			try:
				load_more = driver.find_element_by_class_name('load-more')
				while True:
					try:
						s=wait.until(EC.element_to_be_clickable((By.CLASS_NAME,'load-more')))
						load_more.click()
						time.sleep(2)
					except Exception,e:
						print "E1: ",str(e)
						break
			except Exception,e:
				print "E2 :",str(e)

			print "\n************ALL data LOADED****************\n"

			##Getting the reviews DIV block
			print "\n********Wait while we fetch Reviews and other data**********\n"
			try:
				elem=driver.find_elements_by_xpath('//*[@id="reviewFeed"]/div')
			except Exception,e:
				print str(e)

			##Getting the total review blocks
			g=elem[0].find_elements_by_xpath("//div[contains(@class,'rev-text')]")

			##Getting the reviews and ratings
			ratings = []
			reviews = []
			for block in g:
				rating = block.find_element_by_tag_name('div').get_attribute('aria-label')
				review = block.text
				if rating!=None:
					rating = rating.strip()
					if review not in reviews and review!='' and review!=' ':
						reviews.append(review)
						ratings.append(rating)

			##Getting ReviewId,RestaurantId,RestaurantName
			##RestaurantAddress and datetime
			lis = []
			bis = []
			for block in elem:
				rev_id = block.get_attribute('data-review_id')
				res_id = block.find_element_by_class_name('snippet__name').find_element_by_class_name('snippet__link').get_attribute('data-entity_id')
				res_name = block.find_element_by_class_name('snippet__name').text
				res_addr = block.find_element_by_class_name('snippet__location').text
				datetime = block.find_element_by_tag_name('time').get_attribute('datetime')
				if (rev_id,res_id) not in lis:
					lis.append([rev_id,res_id])
					bis.append([res_name,res_addr,datetime])
			data1=[]
#.........這裏部分代碼省略.........
開發者ID:shoaibkhan94,項目名稱:Zomato-Crawl-Recommendations,代碼行數:101,代碼來源:crawl_user_netowrk.py

示例9: test_idle_formatter

 def test_idle_formatter(self):
     s = shell.idle_formatwarning('Test', UserWarning, 'test_warning.py', 99, 'Line of code')
     self.assertEqual(idlemsg, s)
開發者ID:webiumsk,項目名稱:WOT-0.9.15-CT,代碼行數:3,代碼來源:test_warning.py

示例10: test_shell_show

 def test_shell_show(self):
     with captured_stderr() as f:
         shell.idle_showwarning("Test", UserWarning, "test_warning.py", 99, f, "Line of code")
         self.assertEqual(shellmsg.splitlines(), f.getvalue().splitlines())
開發者ID:webiumsk,項目名稱:WOT-0.9.12-CT,代碼行數:4,代碼來源:test_warning.py


注:本文中的idlelib.PyShell類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。