Added some _cmp_key methods to OperatingSystem class, and also changed the way Platforms are compared. Created a mini inherited class named Arch that inherits from namedtuple. The reason for this is to override the namedtuple __str__ method to make arch tuples look prettier when printed out. Rather than Arch(platform= ... ) it prints to platform-os-target which makes directory paths to packages look cleaner.
This commit is contained in:
parent
35a602baaf
commit
19dca4bcc9
@ -22,6 +22,7 @@
|
|||||||
# along with this program; if not, write to the Free Software Foundation,
|
# along with this program; if not, write to the Free Software Foundation,
|
||||||
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
from collections import namedtuple
|
||||||
import imp
|
import imp
|
||||||
import platform as py_platform
|
import platform as py_platform
|
||||||
import inspect
|
import inspect
|
||||||
@ -178,7 +179,7 @@ def add_operating_system(self, name=None, operating_system=None):
|
|||||||
self.operating_sys[name] = operating_system
|
self.operating_sys[name] = operating_system
|
||||||
|
|
||||||
def operating_system(self, name):
|
def operating_system(self, name):
|
||||||
if name == 'default':
|
if name == 'default_os':
|
||||||
name = self.default_os
|
name = self.default_os
|
||||||
if name == 'front_os':
|
if name == 'front_os':
|
||||||
name = self.front_os
|
name = self.front_os
|
||||||
@ -203,9 +204,10 @@ def __str__(self):
|
|||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def _cmp_key(self):
|
def _cmp_key(self):
|
||||||
return (self.name, (_cmp_key(t) for t in self.targets.values()))
|
return (self.name, (_cmp_key(t) for t in self.targets.values()),
|
||||||
|
(_cmp_key(o) for o in self.operating_sys.values()))
|
||||||
|
|
||||||
|
@key_ordering
|
||||||
class OperatingSystem(object):
|
class OperatingSystem(object):
|
||||||
""" Operating System class. It will include the name and version.
|
""" Operating System class. It will include the name and version.
|
||||||
The biggest attribute to this class will be the compiler finding
|
The biggest attribute to this class will be the compiler finding
|
||||||
@ -222,6 +224,19 @@ def __str__(self):
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return self.__str__()
|
return self.__str__()
|
||||||
|
|
||||||
|
def _cmp_key(self):
|
||||||
|
return (self.name, self.version)
|
||||||
|
|
||||||
|
|
||||||
|
class Arch(namedtuple("Arch", "platform platform_os target")):
|
||||||
|
""" namedtuple for Architecture. Will have it's own __str__ method
|
||||||
|
to make printing out the tuple easier and also won't make directory
|
||||||
|
paths look odd """
|
||||||
|
__slots__ = ()
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return (self.platform.name +"-"+
|
||||||
|
self.platform_os.name + "-" + self.target.name)
|
||||||
|
|
||||||
@memoized
|
@memoized
|
||||||
def all_platforms():
|
def all_platforms():
|
||||||
|
Loading…
Reference in New Issue
Block a user