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
(parentdir_prefix, root, verbose)
| 118 | |
| 119 | |
| 120 | def versions_from_parentdir(parentdir_prefix, root, verbose): |
| 121 | """Try to determine the version from the parent directory name. |
| 122 | |
| 123 | Source tarballs conventionally unpack into a directory that includes both |
| 124 | the project name and a version string. We will also support searching up |
| 125 | two directory levels for an appropriately named parent directory |
| 126 | """ |
| 127 | rootdirs = [] |
| 128 | |
| 129 | for _ in range(3): |
| 130 | dirname = os.path.basename(root) |
| 131 | if dirname.startswith(parentdir_prefix): |
| 132 | return { |
| 133 | "version": dirname[len(parentdir_prefix) :], |
| 134 | "full-revisionid": None, |
| 135 | "dirty": False, |
| 136 | "error": None, |
| 137 | "date": None, |
| 138 | } |
| 139 | rootdirs.append(root) |
| 140 | root = os.path.dirname(root) # up a level |
| 141 | |
| 142 | if verbose: |
| 143 | print( |
| 144 | "Tried directories %s but none started with prefix %s" |
| 145 | % (str(rootdirs), parentdir_prefix) |
| 146 | ) |
| 147 | raise NotThisMethod("rootdir doesn't start with parentdir_prefix") |
| 148 | |
| 149 | |
| 150 | @register_vcs_handler("git", "get_keywords") |
no test coverage detected
searching dependent graphs…