mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	bpo-37760: Avoid cluttering work tree with downloaded Unicode files. (GH-15128)
This commit is contained in:
		
							parent
							
								
									68e495df90
								
							
						
					
					
						commit
						3e4498d35c
					
				
					 2 changed files with 6 additions and 2 deletions
				
			
		
							
								
								
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							|  | @ -74,6 +74,7 @@ PCbuild/arm32/ | |||
| PCbuild/arm64/ | ||||
| PCbuild/obj/ | ||||
| PCbuild/win32/ | ||||
| Tools/unicode/data/ | ||||
| .purify | ||||
| __pycache__ | ||||
| autom4te.cache | ||||
|  |  | |||
|  | @ -887,15 +887,18 @@ class Difference(Exception):pass | |||
|                         normalization_changes)) | ||||
| 
 | ||||
| 
 | ||||
| DATA_DIR = os.path.join('Tools', 'unicode', 'data') | ||||
| 
 | ||||
| def open_data(template, version): | ||||
|     local = template % ('-'+version,) | ||||
|     local = os.path.join(DATA_DIR, template % ('-'+version,)) | ||||
|     if not os.path.exists(local): | ||||
|         import urllib.request | ||||
|         if version == '3.2.0': | ||||
|             # irregular url structure | ||||
|             url = 'http://www.unicode.org/Public/3.2-Update/' + local | ||||
|             url = ('http://www.unicode.org/Public/3.2-Update/'+template) % ('-'+version,) | ||||
|         else: | ||||
|             url = ('http://www.unicode.org/Public/%s/ucd/'+template) % (version, '') | ||||
|         os.makedirs(DATA_DIR, exist_ok=True) | ||||
|         urllib.request.urlretrieve(url, filename=local) | ||||
|     if local.endswith('.txt'): | ||||
|         return open(local, encoding='utf-8') | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Greg Price
						Greg Price