o aL@s@ddlZddlmZddZddZddZed d ZdS) N) namedtuplec Cs|z.t|tr |}nt|tr|d\}}||f}n|jj|jjf}t|dks,J|WSt t fy=t d|w)z Take a model or a string of the form "app_label.ModelName" and return a corresponding ("app_label", "modelname") tuple. If a tuple is passed in, assume it's a valid model tuple already and return it unchanged. .z`Invalid model reference '%s'. String model references must be of the form 'app_label.ModelName'.) isinstancetuplestrsplitlower_meta app_label model_namelen ValueErrorAssertionError)model model_tupler r r8/usr/lib/python3/dist-packages/django/db/models/utils.pymake_model_tuples   rccs0|D]\}}|t|r|n|fVqdS)zp Generate key/value pairs for the given mapping where the values are evaluated if they're callable. N)itemscallable)mappingkvrrrresolve_callablessrcCs t||SN)create_namedtuple_class)namesvaluesrrrunpickle_named_row%s rcs&fdd}tdtdf|ddS)Ncstt|ffSr)rr)selfrrr __reduce__-sz+create_namedtuple_class..__reduce__Rowr)r" __slots__)typer)rr"rr!rr)s  r) functools collectionsrrrr lru_cacherrrrrs