Code Duplication    Length = 23-23 lines in 2 locations

versioneer.py 1 location

@@ 972-994 (lines=23) @@
969
    except NotThisMethod:
970
        pass
971
972
    try:
973
        if cfg.parentdir_prefix:
974
            return versions_from_parentdir(cfg.parentdir_prefix, root, verbose)
975
    except NotThisMethod:
976
        pass
977
978
    return {"version": "0+unknown", "full-revisionid": None,
979
            "dirty": None,
980
            "error": "unable to compute version",
981
            "time": None}
982
'''
983
984
985
@register_vcs_handler("git", "get_keywords")
986
def git_get_keywords(versionfile_abs):
987
    """Extract version information from the given file."""
988
    # the code embedded in _version.py can just fetch the value of these
989
    # keywords. When used from setup.py, we don't want to import _version.py,
990
    # so we do it with a regexp instead. This function is not used from
991
    # _version.py.
992
    keywords = {}
993
    try:
994
        f = open(versionfile_abs, "r")
995
        for line in f.readlines():
996
            if line.strip().startswith("git_refnames ="):
997
                mo = re.search(r'=\s*"(.*)"', line)

bbarchivist/_version.py 1 location

@@ 120-142 (lines=23) @@
117
    return {"version": dirname[len(parentdir_prefix):],
118
            "full-revisionid": None,
119
            "dirty": False, "error": None, "time": None}
120
121
122
@register_vcs_handler("git", "get_keywords")
123
def git_get_keywords(versionfile_abs):
124
    """Extract version information from the given file."""
125
    # the code embedded in _version.py can just fetch the value of these
126
    # keywords. When used from setup.py, we don't want to import _version.py,
127
    # so we do it with a regexp instead. This function is not used from
128
    # _version.py.
129
    keywords = {}
130
    try:
131
        f = open(versionfile_abs, "r")
132
        for line in f.readlines():
133
            if line.strip().startswith("git_refnames ="):
134
                mo = re.search(r'=\s*"(.*)"', line)
135
                if mo:
136
                    keywords["refnames"] = mo.group(1)
137
            if line.strip().startswith("git_full ="):
138
                mo = re.search(r'=\s*"(.*)"', line)
139
                if mo:
140
                    keywords["full"] = mo.group(1)
141
            if line.strip().startswith("git_time ="):
142
                mo = re.search(r'=\s*"(.*)"', line)
143
                if mo:
144
                    keywords["time"] = mo.group(1)
145
        f.close()