mirror of
				https://git.launchpad.net/ubuntu-dev-tools
				synced 2025-10-31 14:04:03 +00:00 
			
		
		
		
	Move vendor_to_distroinfo and codename_to_distribution into ubuntutools.misc
This commit is contained in:
		
							parent
							
								
									1a6fb270b4
								
							
						
					
					
						commit
						16300e471f
					
				| @ -35,8 +35,7 @@ from devscripts.logger import Logger | |||||||
| from ubuntutools.archive import SourcePackage, DebianSourcePackage, UbuntuSourcePackage, DownloadError, rmadison | from ubuntutools.archive import SourcePackage, DebianSourcePackage, UbuntuSourcePackage, DownloadError, rmadison | ||||||
| from ubuntutools.config import UDTConfig, ubu_email | from ubuntutools.config import UDTConfig, ubu_email | ||||||
| from ubuntutools.builder import get_builder | from ubuntutools.builder import get_builder | ||||||
| from ubuntutools.distro_info import vendor_to_distroinfo, codename_to_distribution | from ubuntutools.misc import system_distribution, vendor_to_distroinfo, codename_to_distribution | ||||||
| from ubuntutools.misc import system_distribution |  | ||||||
| from ubuntutools.question import YesNoQuestion | from ubuntutools.question import YesNoQuestion | ||||||
| 
 | 
 | ||||||
| def error(msg): | def error(msg): | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								debian/changelog
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								debian/changelog
									
									
									
									
										vendored
									
									
								
							| @ -26,7 +26,7 @@ ubuntu-dev-tools (0.125) UNRELEASED; urgency=low | |||||||
|   * ubuntutools.misc: Add a new "system_distribution_chain", which returns |   * ubuntutools.misc: Add a new "system_distribution_chain", which returns | ||||||
|     a list starting with the current distribution and working its way up |     a list starting with the current distribution and working its way up | ||||||
|     each distribution's parent. |     each distribution's parent. | ||||||
|   * ubuntutools.distro_info: Add a function to find the distribution that |   * ubuntutools.misc: Add a function to find the distribution that | ||||||
|     used a given release codename. |     used a given release codename. | ||||||
|   * backportpackage, doc/backportpackage.1: Accept codenames from any |   * backportpackage, doc/backportpackage.1: Accept codenames from any | ||||||
|     distribution in the parenting chain. Makes it possible to, e.g., |     distribution in the parenting chain. Makes it possible to, e.g., | ||||||
|  | |||||||
| @ -18,8 +18,6 @@ import csv | |||||||
| import datetime | import datetime | ||||||
| import os | import os | ||||||
| 
 | 
 | ||||||
| from ubuntutools.misc import system_distribution_chain |  | ||||||
| 
 |  | ||||||
| def convert_date(string): | def convert_date(string): | ||||||
|     """Convert a date string in ISO 8601 into a datetime object.""" |     """Convert a date string in ISO 8601 into a datetime object.""" | ||||||
|     if not string: |     if not string: | ||||||
| @ -197,29 +195,3 @@ class UbuntuDistroInfo(DistroInfo): | |||||||
|                    if date <= x["eol"] or |                    if date <= x["eol"] or | ||||||
|                       (x["eol-server"] is not None and date <= x["eol-server"])] |                       (x["eol-server"] is not None and date <= x["eol-server"])] | ||||||
|         return distros |         return distros | ||||||
| 
 |  | ||||||
| _vendor_to_distroinfo = {"Debian": DebianDistroInfo, |  | ||||||
|                          "Ubuntu": UbuntuDistroInfo} |  | ||||||
| def vendor_to_distroinfo(vendor): |  | ||||||
|     """ vendor_to_distroinfo(string) -> DistroInfo class |  | ||||||
| 
 |  | ||||||
|     Convert a string name of a distribution into a DistroInfo subclass |  | ||||||
|     representing that distribution, or None if the distribution is |  | ||||||
|     unknown. |  | ||||||
|     """ |  | ||||||
|     return _vendor_to_distroinfo.get(vendor) |  | ||||||
| 
 |  | ||||||
| def codename_to_distribution(codename): |  | ||||||
|     """ codename_to_distribution(string) -> string |  | ||||||
| 
 |  | ||||||
|     Finds a given release codename in your distribution's genaology |  | ||||||
|     (i.e. looking at the current distribution and its parents), or |  | ||||||
|     print an error message and return None if it can't be found |  | ||||||
|     """ |  | ||||||
|     for distro in system_distribution_chain(): |  | ||||||
|         info = vendor_to_distroinfo(distro) |  | ||||||
|         if not info: |  | ||||||
|             continue |  | ||||||
| 
 |  | ||||||
|         if codename in info().all: |  | ||||||
|             return distro |  | ||||||
|  | |||||||
| @ -29,6 +29,7 @@ import os.path | |||||||
| from subprocess import Popen, PIPE | from subprocess import Popen, PIPE | ||||||
| import sys | import sys | ||||||
| 
 | 
 | ||||||
|  | from ubuntutools import distro_info | ||||||
| from ubuntutools.lp.udtexceptions import PocketDoesNotExistError | from ubuntutools.lp.udtexceptions import PocketDoesNotExistError | ||||||
| 
 | 
 | ||||||
| _system_distribution_chain = [] | _system_distribution_chain = [] | ||||||
| @ -151,3 +152,30 @@ def require_utf8(): | |||||||
|         print >> sys.stderr, ("This program only functions in a UTF-8 locale. " |         print >> sys.stderr, ("This program only functions in a UTF-8 locale. " | ||||||
|                               "Aborting.") |                               "Aborting.") | ||||||
|         sys.exit(1) |         sys.exit(1) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | _vendor_to_distroinfo = {"Debian": distro_info.DebianDistroInfo, | ||||||
|  |                          "Ubuntu": distro_info.UbuntuDistroInfo} | ||||||
|  | def vendor_to_distroinfo(vendor): | ||||||
|  |     """ vendor_to_distroinfo(string) -> DistroInfo class | ||||||
|  | 
 | ||||||
|  |     Convert a string name of a distribution into a DistroInfo subclass | ||||||
|  |     representing that distribution, or None if the distribution is | ||||||
|  |     unknown. | ||||||
|  |     """ | ||||||
|  |     return _vendor_to_distroinfo.get(vendor) | ||||||
|  | 
 | ||||||
|  | def codename_to_distribution(codename): | ||||||
|  |     """ codename_to_distribution(string) -> string | ||||||
|  | 
 | ||||||
|  |     Finds a given release codename in your distribution's genaology | ||||||
|  |     (i.e. looking at the current distribution and its parents), or | ||||||
|  |     print an error message and return None if it can't be found | ||||||
|  |     """ | ||||||
|  |     for distro in system_distribution_chain(): | ||||||
|  |         info = vendor_to_distroinfo(distro) | ||||||
|  |         if not info: | ||||||
|  |             continue | ||||||
|  | 
 | ||||||
|  |         if codename in info().all: | ||||||
|  |             return distro | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user