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