def relative_to_absolute_name(self, modname, level):
<EOL>if self.absolute_import_activated() and level is None:<EOL><INDENT>return modname<EOL><DEDENT>if level:<EOL><INDENT>if self.package:<EOL><INDENT>level = level - <NUM_LIT:1><EOL><DEDENT>if level and self.name.count("<STR_LIT:.>") < level:<EOL><INDENT>raise exceptions.TooManyLevelsError(level=level, name=self.name)<EOL><DEDENT>package_name = self.name.rsplit("<STR_LIT:.>", level)[<NUM_LIT:0>]<EOL><DEDENT>elif self.package:<EOL><INDENT>package_name = self.name<EOL><DEDENT>else:<EOL><INDENT>package_name = self.name.rsplit("<STR_LIT:.>", <NUM_LIT:1>)[<NUM_LIT:0>]<EOL><DEDENT>if package_name:<EOL><INDENT>if not modname:<EOL><INDENT>return package_name<EOL><DEDENT>return "<STR_LIT>" % (package_name, modname)<EOL><DEDENT>return modname<EOL>
Get the absolute module name for a relative import.

        The relative import can be implicit or explicit.

        :param modname: The module name to convert.
        :type modname: str

        :param level: The level of relative import.
        :type level: int

        :returns: The absolute module name.
        :rtype: str

        :raises TooManyLevelsError: When the relative import refers to a
            module too far above this one.