summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorKostis Anagnostopoulos <ankostis@gmail.com>2016-10-01 18:20:13 +0200
committerKostis Anagnostopoulos <ankostis@gmail.com>2016-10-01 18:25:57 +0200
commit9a521681ff8614beb8e2c566cf3c475baca22169 (patch)
tree77365cb808a255eb53889725bfce775b5090330e /setup.py
parentbdf1e68f6bec679edc3feb455596e18c387879c4 (diff)
downloadgitpython-9a521681ff8614beb8e2c566cf3c475baca22169.tar.gz
io, #519: ALL open() --> with open()
+ Some cases had restructuring of code.
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py28
1 files changed, 11 insertions, 17 deletions
diff --git a/setup.py b/setup.py
index d644f005..c7dd25fc 100755
--- a/setup.py
+++ b/setup.py
@@ -15,9 +15,8 @@ import os
import sys
from os import path
-v = open(path.join(path.dirname(__file__), 'VERSION'))
-VERSION = v.readline().strip()
-v.close()
+with open(path.join(path.dirname(__file__), 'VERSION')) as v:
+ VERSION = v.readline().strip()
with open('requirements.txt') as reqs_file:
requirements = reqs_file.read().splitlines()
@@ -50,22 +49,18 @@ class sdist(_sdist):
def _stamp_version(filename):
found, out = False, list()
try:
- f = open(filename, 'r')
+ with open(filename, 'r') as f:
+ for line in f:
+ if '__version__ =' in line:
+ line = line.replace("'git'", "'%s'" % VERSION)
+ found = True
+ out.append(line)
except (IOError, OSError):
print("Couldn't find file %s to stamp version" % filename, file=sys.stderr)
- return
- # END handle error, usually happens during binary builds
- for line in f:
- if '__version__ =' in line:
- line = line.replace("'git'", "'%s'" % VERSION)
- found = True
- out.append(line)
- f.close()
if found:
- f = open(filename, 'w')
- f.writelines(out)
- f.close()
+ with open(filename, 'w') as f:
+ f.writelines(out)
else:
print("WARNING: Couldn't find version line in file %s" % filename, file=sys.stderr)
@@ -109,8 +104,7 @@ setup(
install_requires=install_requires,
test_requirements=test_requires + install_requires,
zip_safe=False,
- long_description="""\
-GitPython is a python library used to interact with Git repositories""",
+ long_description="""GitPython is a python library used to interact with Git repositories""",
classifiers=[
# Picked from
# http://pypi.python.org/pypi?:action=list_classifiers