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