def versions_from_parentdir(parentdir_prefix, root, verbose):
rootdirs = []<EOL>for i in range(<NUM_LIT:3>):<EOL><INDENT>dirname = os.path.basename(root)<EOL>if dirname.startswith(parentdir_prefix):<EOL><INDENT>return {<EOL>"<STR_LIT:version>": dirname[len(parentdir_prefix) :],<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": False,<EOL>"<STR_LIT:error>": None,<EOL>"<STR_LIT:date>": None,<EOL>}<EOL><DEDENT>else:<EOL><INDENT>rootdirs.append(root)<EOL>root = os.path.dirname(root)  <EOL><DEDENT><DEDENT>if verbose:<EOL><INDENT>print(<EOL>"<STR_LIT>"<EOL>% (str(rootdirs), parentdir_prefix)<EOL>)<EOL><DEDENT>raise NotThisMethod("<STR_LIT>")<EOL>
Try to determine the version from the parent directory name.

    Source tarballs conventionally unpack into a directory that includes both
    the project name and a version string. We will also support searching up
    two directory levels for an appropriately named parent directory