Code Duplication    Length = 23-23 lines in 2 locations

versioneer.py 1 location

@@ 1155-1177 (lines=23) @@
1152
    run_command(GITS, ["add", "--"] + files)
1153
1154
1155
def versions_from_parentdir(parentdir_prefix, root, verbose):
1156
    """Try to determine the version from the parent directory name.
1157
1158
    Source tarballs conventionally unpack into a directory that includes both
1159
    the project name and a version string. We will also support searching up
1160
    two directory levels for an appropriately named parent directory
1161
    """
1162
    rootdirs = []
1163
1164
    for i in range(3):
1165
        dirname = os.path.basename(root)
1166
        if dirname.startswith(parentdir_prefix):
1167
            return {"version": dirname[len(parentdir_prefix):],
1168
                    "full-revisionid": None,
1169
                    "dirty": False, "error": None, "date": None}
1170
        else:
1171
            rootdirs.append(root)
1172
            root = os.path.dirname(root)  # up a level
1173
1174
    if verbose:
1175
        print("Tried directories %s but none started with prefix %s" %
1176
              (str(rootdirs), parentdir_prefix))
1177
    raise NotThisMethod("rootdir doesn't start with parentdir_prefix")
1178
1179
SHORT_VERSION_PY = """
1180
# This file was generated by 'versioneer.py' (0.17) from

metpy/_version.py 1 location

@@ 107-129 (lines=23) @@
104
    return stdout, p.returncode
105
106
107
def versions_from_parentdir(parentdir_prefix, root, verbose):
108
    """Try to determine the version from the parent directory name.
109
110
    Source tarballs conventionally unpack into a directory that includes both
111
    the project name and a version string. We will also support searching up
112
    two directory levels for an appropriately named parent directory
113
    """
114
    rootdirs = []
115
116
    for i in range(3):
117
        dirname = os.path.basename(root)
118
        if dirname.startswith(parentdir_prefix):
119
            return {"version": dirname[len(parentdir_prefix):],
120
                    "full-revisionid": None,
121
                    "dirty": False, "error": None, "date": None}
122
        else:
123
            rootdirs.append(root)
124
            root = os.path.dirname(root)  # up a level
125
126
    if verbose:
127
        print("Tried directories %s but none started with prefix %s" %
128
              (str(rootdirs), parentdir_prefix))
129
    raise NotThisMethod("rootdir doesn't start with parentdir_prefix")
130
131
132
@register_vcs_handler("git", "get_keywords")