| @@ 972-994 (lines=23) @@ | ||
| 969 | ''' |
|
| 970 | ||
| 971 | ||
| 972 | @register_vcs_handler("git", "get_keywords") |
|
| 973 | def git_get_keywords(versionfile_abs): |
|
| 974 | """Extract version information from the given file.""" |
|
| 975 | # the code embedded in _version.py can just fetch the value of these |
|
| 976 | # keywords. When used from setup.py, we don't want to import _version.py, |
|
| 977 | # so we do it with a regexp instead. This function is not used from |
|
| 978 | # _version.py. |
|
| 979 | keywords = {} |
|
| 980 | try: |
|
| 981 | f = open(versionfile_abs, "r") |
|
| 982 | for line in f.readlines(): |
|
| 983 | if line.strip().startswith("git_refnames ="): |
|
| 984 | mo = re.search(r'=\s*"(.*)"', line) |
|
| 985 | if mo: |
|
| 986 | keywords["refnames"] = mo.group(1) |
|
| 987 | if line.strip().startswith("git_full ="): |
|
| 988 | mo = re.search(r'=\s*"(.*)"', line) |
|
| 989 | if mo: |
|
| 990 | keywords["full"] = mo.group(1) |
|
| 991 | f.close() |
|
| 992 | except EnvironmentError: |
|
| 993 | pass |
|
| 994 | return keywords |
|
| 995 | ||
| 996 | ||
| 997 | @register_vcs_handler("git", "keywords") |
|
| @@ 120-142 (lines=23) @@ | ||
| 117 | "dirty": False, "error": None} |
|
| 118 | ||
| 119 | ||
| 120 | @register_vcs_handler("git", "get_keywords") |
|
| 121 | def git_get_keywords(versionfile_abs): |
|
| 122 | """Extract version information from the given file.""" |
|
| 123 | # the code embedded in _version.py can just fetch the value of these |
|
| 124 | # keywords. When used from setup.py, we don't want to import _version.py, |
|
| 125 | # so we do it with a regexp instead. This function is not used from |
|
| 126 | # _version.py. |
|
| 127 | keywords = {} |
|
| 128 | try: |
|
| 129 | f = open(versionfile_abs, "r") |
|
| 130 | for line in f.readlines(): |
|
| 131 | if line.strip().startswith("git_refnames ="): |
|
| 132 | mo = re.search(r'=\s*"(.*)"', line) |
|
| 133 | if mo: |
|
| 134 | keywords["refnames"] = mo.group(1) |
|
| 135 | if line.strip().startswith("git_full ="): |
|
| 136 | mo = re.search(r'=\s*"(.*)"', line) |
|
| 137 | if mo: |
|
| 138 | keywords["full"] = mo.group(1) |
|
| 139 | f.close() |
|
| 140 | except EnvironmentError: |
|
| 141 | pass |
|
| 142 | return keywords |
|
| 143 | ||
| 144 | ||
| 145 | @register_vcs_handler("git", "keywords") |
|