def from_dict(cls, d, identifier_str=None):
        """Load a `ResolvedContext` from a dict.

        Args:
            d (dict): Dict containing context data.
            identifier_str (str): String identifying the context, this is only
                used to display in an error string if a serialization version
                mismatch is detected.

        Returns:
            `ResolvedContext` object.
        """
        # check serialization version
        def _print_version(value):
            return '.'.join(str(x) for x in value)

        toks = str(d["serialize_version"]).split('.')
        load_ver = tuple(int(x) for x in toks)
        curr_ver = ResolvedContext.serialize_version

        if load_ver[0] > curr_ver[0]:
            msg = ["The context"]
            if identifier_str:
                msg.append("in %s" % identifier_str)
            msg.append("was written by a newer version of Rez. The load may "
                       "fail (serialize version %d > %d)"
                       % (_print_version(load_ver), _print_version(curr_ver)))
            print >> sys.stderr, ' '.join(msg)

        # create and init the context
        r = ResolvedContext.__new__(ResolvedContext)
        r.load_path = None
        r.pre_resolve_bindings = None

        r.timestamp = d["timestamp"]
        r.building = d["building"]
        r.caching = d["caching"]
        r.implicit_packages = [PackageRequest(x) for x in d["implicit_packages"]]
        r._package_requests = [PackageRequest(x) for x in d["package_requests"]]
        r.package_paths = d["package_paths"]

        r.rez_version = d["rez_version"]
        r.rez_path = d["rez_path"]
        r.user = d["user"]
        r.host = d["host"]
        r.platform = d["platform"]
        r.arch = d["arch"]
        r.os = d["os"]
        r.created = d["created"]
        r.verbosity = d.get("verbosity", 0)

        r.status_ = ResolverStatus[d["status"]]
        r.failure_description = d["failure_description"]

        r.solve_time = d["solve_time"]
        r.load_time = d["load_time"]

        r.graph_string = d["graph"]
        r.graph_ = None

        r._resolved_packages = []
        for d_ in d["resolved_packages"]:
            variant_handle = d_
            if load_ver < (4, 0):
                # -- SINCE SERIALIZE VERSION 4.0
                from rez.utils.backcompat import convert_old_variant_handle
                variant_handle = convert_old_variant_handle(variant_handle)

            variant = get_variant(variant_handle)
            variant.set_context(r)
            r._resolved_packages.append(variant)

        # -- SINCE SERIALIZE VERSION 1

        r.requested_timestamp = d.get("requested_timestamp", 0)

        # -- SINCE SERIALIZE VERSION 2

        r.parent_suite_path = d.get("parent_suite_path")
        r.suite_context_name = d.get("suite_context_name")

        # -- SINCE SERIALIZE VERSION 3

        r.default_patch_lock = PatchLock[d.get("default_patch_lock", "no_lock")]
        patch_locks = d.get("patch_locks", {})
        r.patch_locks = dict((k, PatchLock[v]) for k, v in patch_locks)

        # -- SINCE SERIALIZE VERSION 4.0

        r.from_cache = d.get("from_cache", False)

        # -- SINCE SERIALIZE VERSION 4.1

        data = d.get("package_filter", [])
        r.package_filter = PackageFilterList.from_pod(data)

        # -- SINCE SERIALIZE VERSION 4.2

        data = d.get("package_orderers")
        if data:
            r.package_orderers = [package_order.from_pod(x) for x in data]
        else:
            r.package_orderers = None

        # -- SINCE SERIALIZE VERSION 4.3

        r.num_loaded_packages = d.get("num_loaded_packages", -1)

        # track context usage
        if config.context_tracking_host:
            data = dict((k, v) for k, v in d.iteritems()
                        if k in config.context_tracking_context_fields)

            r._track_context(data, action="sourced")

        return r
def from_dict ( cls , d , identifier_str = None ) : def _print_version ( value ) : return '.' . join ( str ( x ) for x in value ) toks = str ( d [ "serialize_version" ] ) . split ( '.' ) load_ver = tuple ( int ( x ) for x in toks ) curr_ver = ResolvedContext . serialize_version if load_ver [ 0 ] > curr_ver [ 0 ] : msg = [ "The context" ] if identifier_str : msg . append ( "in %s" % identifier_str ) msg . append ( "was written by a newer version of Rez. The load may " "fail (serialize version %d > %d)" % ( _print_version ( load_ver ) , _print_version ( curr_ver ) ) ) print >> sys . stderr , ' ' . join ( msg ) r = ResolvedContext . __new__ ( ResolvedContext ) r . load_path = None r . pre_resolve_bindings = None r . timestamp = d [ "timestamp" ] r . building = d [ "building" ] r . caching = d [ "caching" ] r . implicit_packages = [ PackageRequest ( x ) for x in d [ "implicit_packages" ] ] r . _package_requests = [ PackageRequest ( x ) for x in d [ "package_requests" ] ] r . package_paths = d [ "package_paths" ] r . rez_version = d [ "rez_version" ] r . rez_path = d [ "rez_path" ] r . user = d [ "user" ] r . host = d [ "host" ] r . platform = d [ "platform" ] r . arch = d [ "arch" ] r . os = d [ "os" ] r . created = d [ "created" ] r . verbosity = d . get ( "verbosity" , 0 ) r . status_ = ResolverStatus [ d [ "status" ] ] r . failure_description = d [ "failure_description" ] r . solve_time = d [ "solve_time" ] r . load_time = d [ "load_time" ] r . graph_string = d [ "graph" ] r . graph_ = None r . _resolved_packages = [ ] for d_ in d [ "resolved_packages" ] : variant_handle = d_ if load_ver < ( 4 , 0 ) : from rez . utils . backcompat import convert_old_variant_handle variant_handle = convert_old_variant_handle ( variant_handle ) variant = get_variant ( variant_handle ) variant . set_context ( r ) r . _resolved_packages . append ( variant ) r . requested_timestamp = d . get ( "requested_timestamp" , 0 ) r . parent_suite_path = d . get ( "parent_suite_path" ) r . suite_context_name = d . get ( "suite_context_name" ) r . default_patch_lock = PatchLock [ d . get ( "default_patch_lock" , "no_lock" ) ] patch_locks = d . get ( "patch_locks" , { } ) r . patch_locks = dict ( ( k , PatchLock [ v ] ) for k , v in patch_locks ) r . from_cache = d . get ( "from_cache" , False ) data = d . get ( "package_filter" , [ ] ) r . package_filter = PackageFilterList . from_pod ( data ) data = d . get ( "package_orderers" ) if data : r . package_orderers = [ package_order . from_pod ( x ) for x in data ] else : r . package_orderers = None r . num_loaded_packages = d . get ( "num_loaded_packages" , - 1 ) if config . context_tracking_host : data = dict ( ( k , v ) for k , v in d . iteritems ( ) if k in config . context_tracking_context_fields ) r . _track_context ( data , action = "sourced" ) return r
Load a `ResolvedContext` from a dict.

        Args:
            d (dict): Dict containing context data.
            identifier_str (str): String identifying the context, this is only
                used to display in an error string if a serialization version
                mismatch is detected.

        Returns:
            `ResolvedContext` object.