Skip to content

Commit

Permalink
Merge pull request MDAnalysis#794 from jbarnoud/issue-784-dynamic-aut…
Browse files Browse the repository at this point in the history
…hors-py3

Dynamic author list works on python 3
  • Loading branch information
mnmelo committed Mar 21, 2016
2 parents c282d66 + 93b5841 commit bddbd81
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
16 changes: 11 additions & 5 deletions package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@
from __future__ import print_function
from setuptools import setup, Extension, find_packages
from distutils.ccompiler import new_compiler
import codecs
import os
import sys
import shutil
import tempfile
import warnings

# Make sure I have the right Python version.
if sys.version_info[:2] < (2, 7):
Expand Down Expand Up @@ -364,7 +366,7 @@ def dynamic_author_list():
"Chronological list of authors" title.
"""
authors = []
with open('AUTHORS') as infile:
with codecs.open('AUTHORS', encoding='utf-8') as infile:
# An author is a bullet point under the title "Chronological list of
# authors". We first want move the cursor down to the title of
# interest.
Expand All @@ -389,7 +391,7 @@ def dynamic_author_list():
break
elif line.strip()[:2] == '- ':
# This is a bullet point, so it should be an author name.
name = line.strip()[2:].strip().decode('utf-8')
name = line.strip()[2:].strip()
authors.append(name)

# So far, the list of authors is sorted chronologically. We want it
Expand All @@ -403,7 +405,8 @@ def dynamic_author_list():
+ authors + ['Oliver Beckstein'])

# Write the authors.py file.
with open('MDAnalysis/authors.py', 'w') as outfile:
out_path = 'MDAnalysis/authors.py'
with codecs.open(out_path, 'w', encoding='utf-8') as outfile:
# Write the header
header = '''\
#-*- coding:utf-8 -*-
Expand All @@ -417,11 +420,14 @@ def dynamic_author_list():
template = u'__authors__ = [\n{}\n]'
author_string = u',\n'.join(u' u"{}"'.format(name)
for name in authors)
print(template.format(author_string).encode('utf-8'), file=outfile)
print(template.format(author_string), file=outfile)


if __name__ == '__main__':
dynamic_author_list()
try:
dynamic_author_list()
except (OSError, IOError):
warnings.warn('Cannot write the list of authors.')

with open("SUMMARY.txt") as summary:
LONG_DESCRIPTION = summary.read()
Expand Down
16 changes: 11 additions & 5 deletions testsuite/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@
from __future__ import print_function
from setuptools import setup, Extension, find_packages

import codecs
import sys
import os
import glob
import warnings


def dynamic_author_list():
Expand All @@ -55,7 +57,7 @@ def dynamic_author_list():
"Chronological list of authors" title.
"""
authors = []
with open('AUTHORS') as infile:
with codecs.open('AUTHORS', encoding='utf-8') as infile:
# An author is a bullet point under the title "Chronological list of
# authors". We first want move the cursor down to the title of
# interest.
Expand All @@ -80,7 +82,7 @@ def dynamic_author_list():
break
elif line.strip()[:2] == '- ':
# This is a bullet point, so it should be an author name.
name = line.strip()[2:].strip().decode('utf-8')
name = line.strip()[2:].strip()
authors.append(name)

# So far, the list of authors is sorted chronologically. We want it
Expand All @@ -94,7 +96,8 @@ def dynamic_author_list():
+ authors + ['Oliver Beckstein'])

# Write the authors.py file.
with open('MDAnalysisTests/authors.py', 'w') as outfile:
out_path = 'MDAnalysisTests/authors.py'
with codecs.open(out_path, 'w', encoding='utf-8') as outfile:
# Write the header
header = '''\
#-*- coding:utf-8 -*-
Expand All @@ -108,7 +111,7 @@ def dynamic_author_list():
template = u'__authors__ = [\n{}\n]'
author_string = u',\n'.join(u' u"{}"'.format(name)
for name in authors)
print(template.format(author_string).encode('utf-8'), file=outfile)
print(template.format(author_string), file=outfile)


# Make sure I have the right Python version.
Expand All @@ -120,7 +123,10 @@ def dynamic_author_list():


if __name__ == '__main__':
dynamic_author_list()
try:
dynamic_author_list()
except (OSError, IOError):
warnings.warn('Cannot write the list of authors.')

RELEASE = "0.14.1-dev0" # this must be in-sync with MDAnalysis
LONG_DESCRIPTION = \
Expand Down

0 comments on commit bddbd81

Please sign in to comment.