当前位置: 首页>>代码示例>>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;未经允许,请勿转载。