mongoframes/frames.py
def _projection_to_paths(cls, root_key, projection):
        """
        Expand a $sub/$sub. projection to a single projection of True (if
        inclusive) or a map of full paths (e.g `employee.company.tel`).
        """

        # Referenced projections are handled separately so just flag the
        # reference field to true.
        if '$ref' in projection:
            return True

        inclusive = True
        sub_projection = {}
        for key, value in projection.items():
            if key in ['$sub', '$sub.']:
                continue

            if key.startswith('$'):
                sub_projection[root_key] = {key: value}
                inclusive = False
                continue

            sub_key = root_key + '.' + key

            if isinstance(value, dict):
                sub_value = cls._projection_to_paths(sub_key, value)
                if isinstance(sub_value, dict):
                    sub_projection.update(sub_value)
                else:
                    sub_projection[sub_key] = True

            else:
                sub_projection[sub_key] = True
                inclusive = False

        if inclusive:
            # No specific keys so this is inclusive
            return True

        return sub_projection

        Expand a $sub/$sub. projection to a single projection of True (if
        inclusive) or a map of full paths (e.g `employee.company.tel`).
        
Expand a $sub/$sub. projection to a single projection of True (if
inclusive) or a map of full paths .
Expand a $sub / $sub . projection to a single projection of True ( if inclusive ) or a map of full paths .
def _projection_to_paths(cls, root_key, projection):
        if '$ref' in projection:
            return True
        inclusive = True
        sub_projection = {}
        for key, value in projection.items():
            if key in ['$sub', '$sub.']:
                continue
            if key.startswith('$'):
                sub_projection[root_key] = {key: value}
                inclusive = False
                continue
            sub_key = root_key + '.' + key
            if isinstance(value, dict):
                sub_value = cls._projection_to_paths(sub_key, value)
                if isinstance(sub_value, dict):
                    sub_projection.update(sub_value)
                else:
                    sub_projection[sub_key] = True
            else:
                sub_projection[sub_key] = True
                inclusive = False
        if inclusive:
            return True
        return sub_projection
def _projection_to_paths ( cls , root_key , projection ) : if '$ref' in projection : return True inclusive = True sub_projection = { } for key , value in projection . items ( ) : if key in [ '$sub' , '$sub.' ] : continue if key . startswith ( '$' ) : sub_projection [ root_key ] = { key : value } inclusive = False continue sub_key = root_key + '.' + key if isinstance ( value , dict ) : sub_value = cls . _projection_to_paths ( sub_key , value ) if isinstance ( sub_value , dict ) : sub_projection . update ( sub_value ) else : sub_projection [ sub_key ] = True else : sub_projection [ sub_key ] = True inclusive = False if inclusive : return True return sub_projection
Expand a $sub/$sub.
Expand a $sub / $sub .
"""
        Expand a $sub/$sub. projection to a single projection of True (if
        inclusive) or a map of full paths (e.g `employee.company.tel`).
        """ # Referenced projections are handled separately so just flag the # reference field to true. # No specific keys so this is inclusive
cls
root_key
projection