Code Duplication    Length = 23-23 lines in 2 locations

versioneer.py 1 location

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

loghub/_version.py 1 location

@@ 107-129 (lines=23) @@
104
    if sys.version_info[0] >= 3:
105
        stdout = stdout.decode()
106
    if p.returncode != 0:
107
        if verbose:
108
            print("unable to run %s (error)" % dispcmd)
109
            print("stdout was %s" % stdout)
110
        return None, p.returncode
111
    return stdout, p.returncode
112
113
114
def versions_from_parentdir(parentdir_prefix, root, verbose):
115
    """Try to determine the version from the parent directory name.
116
117
    Source tarballs conventionally unpack into a directory that includes both
118
    the project name and a version string. We will also support searching up
119
    two directory levels for an appropriately named parent directory
120
    """
121
    rootdirs = []
122
123
    for i in range(3):
124
        dirname = os.path.basename(root)
125
        if dirname.startswith(parentdir_prefix):
126
            return {
127
                "version": dirname[len(parentdir_prefix):],
128
                "full-revisionid": None,
129
                "dirty": False,
130
                "error": None,
131
                "date": None
132
            }