def get_module_part(dotted_name, context_file=None):
<EOL>if dotted_name.startswith("<STR_LIT>"):<EOL><INDENT>return "<STR_LIT>"<EOL><DEDENT>parts = dotted_name.split("<STR_LIT:.>")<EOL>if context_file is not None:<EOL><INDENT>if parts[<NUM_LIT:0>] in BUILTIN_MODULES:<EOL><INDENT>if len(parts) > <NUM_LIT:2>:<EOL><INDENT>raise ImportError(dotted_name)<EOL><DEDENT>return parts[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>path = None<EOL>starti = <NUM_LIT:0><EOL>if parts[<NUM_LIT:0>] == "<STR_LIT>":<EOL><INDENT>assert (<EOL>context_file is not None<EOL>), "<STR_LIT>"<EOL>path = []  <EOL>starti = <NUM_LIT:1><EOL><DEDENT>while parts[starti] == "<STR_LIT>":  <EOL><INDENT>starti += <NUM_LIT:1><EOL>context_file = os.path.dirname(context_file)<EOL><DEDENT>for i in range(starti, len(parts)):<EOL><INDENT>try:<EOL><INDENT>file_from_modpath(<EOL>parts[starti : i + <NUM_LIT:1>], path=path, context_file=context_file<EOL>)<EOL><DEDENT>except ImportError:<EOL><INDENT>if i < max(<NUM_LIT:1>, len(parts) - <NUM_LIT:2>):<EOL><INDENT>raise<EOL><DEDENT>return "<STR_LIT:.>".join(parts[:i])<EOL><DEDENT><DEDENT>return dotted_name<EOL>
given a dotted name return the module part of the name :

    >>> get_module_part('astroid.as_string.dump')
    'astroid.as_string'

    :type dotted_name: str
    :param dotted_name: full name of the identifier we are interested in

    :type context_file: str or None
    :param context_file:
      context file to consider, necessary if the identifier has been
      introduced using a relative import unresolvable in the actual
      context (i.e. modutils)


    :raise ImportError: if there is no such module in the directory

    :rtype: str or None
    :return:
      the module part of the name or None if we have not been able at
      all to import the given name

    XXX: deprecated, since it doesn't handle package precedence over module
    (see #10066)