1""" This module represents an abstraction of an lldb target / host platform. """ 2 3from __future__ import absolute_import 4 5# System modules 6import itertools 7 8# Third-party modules 9import six 10 11# LLDB modules 12import lldb 13 14windows, linux, macosx, darwin, ios, tvos, watchos, bridgeos, darwin_all, darwin_embedded, freebsd, netbsd, bsd_all, android = range( 15 14) 16 17__name_lookup = { 18 windows: ["windows"], 19 linux: ["linux"], 20 macosx: ["macosx"], 21 darwin: ["darwin"], 22 ios: ["ios"], 23 tvos: ["tvos"], 24 watchos: ["watchos"], 25 bridgeos: ["bridgeos"], 26 darwin_all: ["macosx", "darwin", "ios", "tvos", "watchos", "bridgeos"], 27 darwin_embedded: ["ios", "tvos", "watchos", "bridgeos"], 28 freebsd: ["freebsd"], 29 netbsd: ["netbsd"], 30 bsd_all: ["freebsd", "netbsd"], 31 android: ["android"] 32} 33 34 35def translate(values): 36 37 if isinstance(values, six.integer_types): 38 # This is a value from the platform enumeration, translate it. 39 return __name_lookup[values] 40 elif isinstance(values, six.string_types): 41 # This is a raw string, return it. 42 return [values] 43 elif hasattr(values, "__iter__"): 44 # This is an iterable, convert each item. 45 result = [translate(x) for x in values] 46 result = list(itertools.chain(*result)) 47 return result 48 return values 49