Skip to content

Commit 98af1a6

Browse files
committed
Pervasively switch to unicode_literals
Resolves many inconsistent appearances of strings as sometimes unicode and sometimes not. Requires conversion of `__all__` entries because ["Python 2 names are strings, not unicode values"](https://stackoverflow.com/a/19913680/2019542) Force unit to render as native string Force .gz filenames to be native
1 parent cb129d1 commit 98af1a6

File tree

404 files changed

+1001
-217
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

404 files changed

+1001
-217
lines changed

_setup/build_docs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import unicode_literals
12
from distutils.core import Command
23
import os
34

_setup/changelog.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Adapted from: https://gist.github.com/patrickfuller/e2ea8a94badc5b6967ef3ca0a9452a43
44
"""
55
from __future__ import print_function
6+
from __future__ import unicode_literals
67

78
import os
89
import textwrap

_setup/copy_script.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import print_function
2+
from __future__ import unicode_literals
23
from builtins import input
34
import os
45
from distutils.core import Command
@@ -33,13 +34,13 @@ def finalize_options(self):
3334
ans = "junk"
3435

3536
while (len(ans) > 0) and ("yes".find(ans.lower()) is not 0) and ("no".find(ans.lower()) is not 0):
36-
ans = input("The file '%s' already exists. Overwrite? [n] "%self.To)
37+
ans = eval(input("The file '%s' already exists. Overwrite? [n] "%self.To))
3738

3839
if ans is '':
3940
ans = 'no'
4041

4142
if ("no".find(ans.lower()) is 0):
42-
self.To = input("Please give a name for the ouput file: ")
43+
self.To = eval(input("Please give a name for the ouput file: "))
4344
self.finalize_options()
4445

4546
def run(self):

_setup/release.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""setuptools command to prepare FiPy for release"""
2+
from __future__ import unicode_literals
23

34
from distutils.core import Command
45
import glob

_setup/upload_products.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import print_function
2+
from __future__ import unicode_literals
23
from distutils.core import Command
34
import os
45

documentation/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# All configuration values have a default; values that are commented out
1212
# serve to show the default.
1313

14+
from __future__ import unicode_literals
1415
import sys, os
1516

1617
# If extensions (or modules to document with autodoc) are in another directory,

documentation/pyplots/threadanalyze.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import unicode_literals
12
from matplotlib import pyplot as plt
23
import pandas as pd
34

documentation/sphinxext/docscrape.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
33
"""
44
from __future__ import print_function
5+
from __future__ import unicode_literals
56

7+
from future import standard_library
8+
standard_library.install_aliases()
9+
from builtins import object
610
import inspect
711
import textwrap
812
import re
913
import pydoc
10-
from StringIO import StringIO
14+
from io import StringIO
1115
from warnings import warn
1216
4
1317
class Reader(object):
@@ -370,7 +374,7 @@ def _str_index(self):
370374
idx = self['index']
371375
out = []
372376
out += ['.. index:: %s' % idx.get('default', '')]
373-
for section, references in idx.items():
377+
for section, references in list(idx.items()):
374378
if section == 'default':
375379
continue
376380
out += [' :%s: %s' % (section, ', '.join(references))]

documentation/sphinxext/docscrape_sphinx.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import absolute_import
2+
from __future__ import unicode_literals
23
import re, inspect, textwrap, pydoc
34
from .docscrape import NumpyDocString, FunctionDoc, ClassDoc
45

@@ -74,7 +75,7 @@ def _str_index(self):
7475
return out
7576

7677
out += ['.. index:: %s' % idx.get('default', '')]
77-
for section, references in idx.items():
78+
for section, references in list(idx.items()):
7879
if section == 'default':
7980
continue
8081
elif section == 'refguide':

documentation/sphinxext/example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import print_function
2+
from __future__ import unicode_literals
23
import os.path
34
import posixpath
45

documentation/sphinxext/numpydoc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"""
1818
from __future__ import absolute_import
1919
from __future__ import print_function
20+
from __future__ import unicode_literals
2021

2122
from builtins import str
2223
import os, re, pydoc

documentation/sphinxext/redirecting_html.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
from __future__ import unicode_literals
2+
from future import standard_library
3+
standard_library.install_aliases()
14
from docutils import nodes
2-
import urlparse
5+
import urllib.parse
36

47
from sphinx.builders.html import StandaloneHTMLBuilder
58

@@ -14,7 +17,7 @@ def write_doc(self, docname, doctree):
1417
for node in doctree.traverse(nodes.reference):
1518
try:
1619
uri = node['refuri']
17-
uri = urlparse.urlparse(uri)
20+
uri = urllib.parse.urlparse(uri)
1821
if uri.scheme in ["http", "https"]:
1922
if not uri.netloc.endswith("nist.gov"):
2023
node['refuri'] = "/cgi-bin/redirect.py?url=" + uri.geturl()

documentation/tutorial/package/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
their own chapters; rather, their contents will be described in the chapter
88
for their containing package.
99
"""
10+
from __future__ import unicode_literals
1011

1112
__docformat__ = 'restructuredtext'

documentation/tutorial/package/subpackage/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
their own chapters; rather, their contents will be described in the chapter
88
for their containing package.
99
"""
10+
from __future__ import unicode_literals
1011

1112
__docformat__ = 'restructuredtext'

documentation/tutorial/package/subpackage/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
1212
in which case you can refer simply to :mod:`~package.subpackage.base`.
1313
"""
14+
from __future__ import unicode_literals
15+
from builtins import object
1416
__docformat__ = 'restructuredtext'
1517

16-
class Base:
18+
class Base(object):
1719
"""
1820
With very few exceptions, the name of a class will be the capitalized
1921
form of the module it resides in. Depending on how you imported the

documentation/tutorial/package/subpackage/object.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import unicode_literals
12

23
__docformat__ = 'restructuredtext'
34

examples/benchmarking/benchmarker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import print_function
22
from __future__ import division
3+
from __future__ import unicode_literals
34
from builtins import str
45
from past.utils import old_div
56
import os

examples/benchmarking/size.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import print_function
2+
from __future__ import unicode_literals
23
import os
34
import sys
45
import re

examples/benchmarking/steps.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import print_function
2+
from __future__ import unicode_literals
23
from builtins import range
34
import os
45
import sys

examples/benchmarking/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import unicode_literals
12
import re
23

34
import numpy

examples/benchmarking/versions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import print_function
2+
from __future__ import unicode_literals
23
import os
34
import re
45
import shutil

examples/cahnHilliard/mesh2D.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,13 @@
108108
:alt: evolution of Cahn-Hilliard phase separation at t = 30, 100 and 1000
109109
110110
"""
111+
from __future__ import unicode_literals
111112
from builtins import input
112113
__docformat__ = 'restructuredtext'
113114

114115
if __name__ == '__main__':
115116
import fipy.tests.doctestPlus
116117
exec(fipy.tests.doctestPlus._getScript())
117118

118-
input('finished')
119+
eval(input('finished'))
119120

examples/cahnHilliard/mesh2DCoupled.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,14 @@
169169
True
170170
171171
"""
172+
from __future__ import unicode_literals
172173
from builtins import input
173174
__docformat__ = 'restructuredtext'
174175

175176
if __name__ == '__main__':
176177
import fipy.tests.doctestPlus
177178
exec(fipy.tests.doctestPlus._getScript())
178179

179-
input('finished')
180+
eval(input('finished'))
180181

181182

examples/cahnHilliard/mesh3D.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,12 @@
7474
:align: center
7575
:alt: snapshot of Cahn-Hilliard phase separation in 3D with cutaway
7676
"""
77+
from __future__ import unicode_literals
7778
from builtins import input
7879
__docformat__ = 'restructuredtext'
7980

8081
if __name__ == '__main__':
8182
import fipy.tests.doctestPlus
8283
exec(fipy.tests.doctestPlus._getScript())
8384

84-
input('finished')
85+
eval(input('finished'))

examples/cahnHilliard/sphere.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,13 @@
109109
:alt: Cahn-Hilliard phase separation on the surface of a sphere with a rendering of the mesh
110110
111111
"""
112+
from __future__ import unicode_literals
112113
from builtins import input
113114
__docformat__ = 'restructuredtext'
114115

115116
if __name__ == '__main__':
116117
import fipy.tests.doctestPlus
117118
exec(fipy.tests.doctestPlus._getScript())
118119

119-
input('finished')
120+
eval(input('finished'))
120121

examples/cahnHilliard/sphereDaemon.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import unicode_literals
12
import sys
23

34
try:

examples/cahnHilliard/tanh1D.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,15 @@
151151
1
152152
153153
"""
154+
from __future__ import unicode_literals
154155
from builtins import input
155156
__docformat__ = 'restructuredtext'
156157

157158
if __name__ == '__main__':
158159
import fipy.tests.doctestPlus
159160
exec(fipy.tests.doctestPlus._getScript())
160161

161-
input('finished')
162+
eval(input('finished'))
162163

163164

164165

examples/cahnHilliard/test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import unicode_literals
12
from fipy.tests.doctestPlus import _LateImportDocTestSuite
23
import fipy.tests.testProgram
34

examples/chemotaxis/input.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
2727
"""
2828
from __future__ import division
29+
from __future__ import unicode_literals
2930

3031
from builtins import input
3132
from builtins import range
@@ -112,5 +113,5 @@
112113

113114
KMViewer.plot()
114115

115-
input("finished")
116+
eval(input("finished"))
116117

examples/chemotaxis/input2D.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
2727
"""
2828
from __future__ import division
29+
from __future__ import unicode_literals
2930

3031
from builtins import input
3132
from builtins import range
@@ -116,5 +117,5 @@
116117
KMViewer.plot()
117118
TMViewer.plot()
118119

119-
input("finished")
120+
eval(input("finished"))
120121

examples/chemotaxis/parameters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Input file for parameters
44
55
"""
6+
from __future__ import unicode_literals
67

78
parameters = { 'case 1' : { 'P3' : 0.21967,
89
'P2' : 0.47202,

examples/chemotaxis/test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import unicode_literals
12
from fipy.tests.doctestPlus import _LateImportDocTestSuite
23
import fipy.tests.testProgram
34

examples/convection/advection/explicitUpwind.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
order explicit upwind scheme.
44
"""
55
from __future__ import division
6+
from __future__ import unicode_literals
67

78
from builtins import input
89
from builtins import range
@@ -44,4 +45,4 @@
4445
solver = LinearLUSolver(tolerance=1.e-15, iterations=2000))
4546
viewer.plot()
4647
viewer.plot()
47-
input('finished')
48+
eval(input('finished'))

examples/convection/advection/implicitUpwind.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
order implicit upwind scheme.
44
"""
55
from __future__ import division
6+
from __future__ import unicode_literals
67

78
from builtins import range
89
from builtins import input
@@ -39,11 +40,11 @@
3940

4041
viewer = Viewer(vars=(var,))
4142
viewer.plot()
42-
input("press key to continue")
43+
eval(input("press key to continue"))
4344
for step in range(steps):
4445
eq.solve(var,
4546
dt = timeStepDuration,
4647
solver = LinearLUSolver(tolerance = 1.e-15))
4748
viewer.plot()
4849
viewer.plot()
49-
input('finished')
50+
eval(input('finished'))

examples/convection/advection/vanLeerUpwind.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"""
3030
from __future__ import print_function
3131
from __future__ import division
32+
from __future__ import unicode_literals
3233

3334
from builtins import input
3435
from builtins import range
@@ -87,5 +88,5 @@
8788

8889
print('maximum absolute difference between periodic and non-periodic grids:', abs(var1[old_div(nx, 4):old_div(3 * nx, 4)] - newVar2).max())
8990

90-
input('finished')
91+
eval(input('finished'))
9192

examples/convection/exponential1D/cylindricalMesh1D.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,13 @@
9494
... viewer = Viewer(vars=var)
9595
... viewer.plot()
9696
"""
97+
from __future__ import unicode_literals
9798
from builtins import input
9899
__docformat__ = 'restructuredtext'
99100

100101
if __name__ == '__main__':
101102
import fipy.tests.doctestPlus
102103
exec(fipy.tests.doctestPlus._getScript())
103104

104-
input('finished')
105+
eval(input('finished'))
105106

0 commit comments

Comments
 (0)