Code Duplication    Length = 27-27 lines in 2 locations

versioneer.py 1 location

@@ 944-970 (lines=27) @@
941
'''
942
943
944
@register_vcs_handler("git", "get_keywords")
945
def git_get_keywords(versionfile_abs):
946
    """Extract version information from the given file."""
947
    # the code embedded in _version.py can just fetch the value of these
948
    # keywords. When used from setup.py, we don't want to import _version.py,
949
    # so we do it with a regexp instead. This function is not used from
950
    # _version.py.
951
    keywords = {}
952
    try:
953
        f = open(versionfile_abs, "r")
954
        for line in f.readlines():
955
            if line.strip().startswith("git_refnames ="):
956
                mo = re.search(r'=\s*"(.*)"', line)
957
                if mo:
958
                    keywords["refnames"] = mo.group(1)
959
            if line.strip().startswith("git_full ="):
960
                mo = re.search(r'=\s*"(.*)"', line)
961
                if mo:
962
                    keywords["full"] = mo.group(1)
963
            if line.strip().startswith("git_date ="):
964
                mo = re.search(r'=\s*"(.*)"', line)
965
                if mo:
966
                    keywords["date"] = mo.group(1)
967
        f.close()
968
    except EnvironmentError:
969
        pass
970
    return keywords
971
972
973
@register_vcs_handler("git", "keywords")

rna_tools/_version.py 1 location

@@ 132-158 (lines=27) @@
129
    raise NotThisMethod("rootdir doesn't start with parentdir_prefix")
130
131
132
@register_vcs_handler("git", "get_keywords")
133
def git_get_keywords(versionfile_abs):
134
    """Extract version information from the given file."""
135
    # the code embedded in _version.py can just fetch the value of these
136
    # keywords. When used from setup.py, we don't want to import _version.py,
137
    # so we do it with a regexp instead. This function is not used from
138
    # _version.py.
139
    keywords = {}
140
    try:
141
        f = open(versionfile_abs, "r")
142
        for line in f.readlines():
143
            if line.strip().startswith("git_refnames ="):
144
                mo = re.search(r'=\s*"(.*)"', line)
145
                if mo:
146
                    keywords["refnames"] = mo.group(1)
147
            if line.strip().startswith("git_full ="):
148
                mo = re.search(r'=\s*"(.*)"', line)
149
                if mo:
150
                    keywords["full"] = mo.group(1)
151
            if line.strip().startswith("git_date ="):
152
                mo = re.search(r'=\s*"(.*)"', line)
153
                if mo:
154
                    keywords["date"] = mo.group(1)
155
        f.close()
156
    except EnvironmentError:
157
        pass
158
    return keywords
159
160
161
@register_vcs_handler("git", "keywords")