mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
shorter and faster version extraction from __init__.py
This commit is contained in:
@@ -30,12 +30,8 @@ requires = []
|
||||
|
||||
version = ''
|
||||
with open('requests/__init__.py', 'r') as fd:
|
||||
reg = re.compile(r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]')
|
||||
for line in fd:
|
||||
m = reg.match(line)
|
||||
if m:
|
||||
version = m.group(1)
|
||||
break
|
||||
version = re.search(r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
|
||||
fd.read()).group(1)
|
||||
|
||||
if not version:
|
||||
raise RuntimeError('Cannot find version information')
|
||||
|
||||
Reference in New Issue
Block a user