Skip to content

Commit fafdf0f

Browse files
committed
black edits
1 parent 84234ff commit fafdf0f

File tree

102 files changed

+4568
-3154
lines changed

Some content is hidden

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

102 files changed

+4568
-3154
lines changed

Diff for: conda-recipe/expandpdfguibase.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import sys
44
from pkg_resources import Requirement, resource_filename
55

6-
pkg = Requirement.parse('diffpy.pdfgui')
7-
PDFGUIPATH = resource_filename(pkg, '')
6+
pkg = Requirement.parse("diffpy.pdfgui")
7+
PDFGUIPATH = resource_filename(pkg, "")
88
assert PDFGUIPATH.lower().startswith(sys.prefix.lower())
9-
PDFGUIBASE = PDFGUIPATH[len(sys.prefix):].replace('\\', '/').strip('/')
9+
PDFGUIBASE = PDFGUIPATH[len(sys.prefix) :].replace("\\", "/").strip("/")
1010

1111
if __name__ == "__main__":
1212
with open(sys.argv[1]) as fp:
1313
content = fp.read()
14-
output = content.replace('@PDFGUIBASE@', PDFGUIBASE)
14+
output = content.replace("@PDFGUIBASE@", PDFGUIBASE)
1515
sys.stdout.write(output)

Diff for: conda-recipe/run_test.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
22

33
import diffpy.pdfgui.tests
4+
45
assert diffpy.pdfgui.tests.testdeps().wasSuccessful()

Diff for: setup.py

+78-73
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,29 @@
1515

1616
# Use this version when git data are not available, like in git zip archive.
1717
# Update when tagging a new release.
18-
FALLBACK_VERSION = '2.0.4'
18+
FALLBACK_VERSION = "2.0.4"
1919

2020
# determine if we run with Python 3.
21-
PY3 = (sys.version_info[0] == 3)
21+
PY3 = sys.version_info[0] == 3
2222

2323
# versioncfgfile holds version data for git commit hash and date.
2424
# It must reside in the same directory as version.py.
2525
MYDIR = os.path.dirname(os.path.abspath(__file__))
26-
versioncfgfile = os.path.join(MYDIR, 'src/diffpy/pdfgui/version.cfg')
27-
gitarchivecfgfile = os.path.join(MYDIR, '.gitarchive.cfg')
26+
versioncfgfile = os.path.join(MYDIR, "src/diffpy/pdfgui/version.cfg")
27+
gitarchivecfgfile = os.path.join(MYDIR, ".gitarchive.cfg")
28+
2829

2930
def gitinfo():
3031
from subprocess import Popen, PIPE
32+
3133
kw = dict(stdout=PIPE, cwd=MYDIR, universal_newlines=True)
32-
proc = Popen(['git', 'describe', '--tags', '--match=v[[:digit:]]*'], **kw)
34+
proc = Popen(["git", "describe", "--tags", "--match=v[[:digit:]]*"], **kw)
3335
desc = proc.stdout.read()
34-
proc = Popen(['git', 'log', '-1', '--format=%H %ct %ci'], **kw)
36+
proc = Popen(["git", "log", "-1", "--format=%H %ct %ci"], **kw)
3537
glog = proc.stdout.read()
3638
rv = {}
37-
rv['version'] = '.post'.join(desc.strip().split('-')[:2]).lstrip('v')
38-
rv['commit'], rv['timestamp'], rv['date'] = glog.strip().split(None, 2)
39+
rv["version"] = ".post".join(desc.strip().split("-")[:2]).lstrip("v")
40+
rv["commit"], rv["timestamp"], rv["date"] = glog.strip().split(None, 2)
3941
return rv
4042

4143

@@ -44,19 +46,19 @@ def getversioncfg():
4446
from configparser import RawConfigParser
4547
else:
4648
from ConfigParser import RawConfigParser
47-
vd0 = dict(version=FALLBACK_VERSION, commit='', date='', timestamp=0)
49+
vd0 = dict(version=FALLBACK_VERSION, commit="", date="", timestamp=0)
4850
# first fetch data from gitarchivecfgfile, ignore if it is unexpanded
4951
g = vd0.copy()
5052
cp0 = RawConfigParser(vd0)
5153
cp0.read(gitarchivecfgfile)
52-
if len(cp0.get('DEFAULT', 'commit')) > 20:
54+
if len(cp0.get("DEFAULT", "commit")) > 20:
5355
g = cp0.defaults()
54-
mx = re.search(r'\btag: v(\d[^,]*)', g.pop('refnames'))
56+
mx = re.search(r"\btag: v(\d[^,]*)", g.pop("refnames"))
5557
if mx:
56-
g['version'] = mx.group(1)
58+
g["version"] = mx.group(1)
5759
# then try to obtain version data from git.
58-
gitdir = os.path.join(MYDIR, '.git')
59-
if os.path.exists(gitdir) or 'GIT_DIR' in os.environ:
60+
gitdir = os.path.join(MYDIR, ".git")
61+
if os.path.exists(gitdir) or "GIT_DIR" in os.environ:
6062
try:
6163
g = gitinfo()
6264
except OSError:
@@ -65,94 +67,97 @@ def getversioncfg():
6567
cp = RawConfigParser()
6668
cp.read(versioncfgfile)
6769
d = cp.defaults()
68-
rewrite = not d or (g['commit'] and (
69-
g['version'] != d.get('version') or g['commit'] != d.get('commit')))
70+
rewrite = not d or (
71+
g["commit"]
72+
and (g["version"] != d.get("version") or g["commit"] != d.get("commit"))
73+
)
7074
if rewrite:
71-
cp.set('DEFAULT', 'version', g['version'])
72-
cp.set('DEFAULT', 'commit', g['commit'])
73-
cp.set('DEFAULT', 'date', g['date'])
74-
cp.set('DEFAULT', 'timestamp', g['timestamp'])
75-
with open(versioncfgfile, 'w') as fp:
75+
cp.set("DEFAULT", "version", g["version"])
76+
cp.set("DEFAULT", "commit", g["commit"])
77+
cp.set("DEFAULT", "date", g["date"])
78+
cp.set("DEFAULT", "timestamp", g["timestamp"])
79+
with open(versioncfgfile, "w") as fp:
7680
cp.write(fp)
7781
return cp
7882

83+
7984
versiondata = getversioncfg()
8085

8186

8287
def dirglob(d, *patterns):
8388
from glob import glob
89+
8490
rv = []
8591
for p in patterns:
8692
rv += glob(os.path.join(d, p))
8793
return rv
8894

8995

90-
with open(os.path.join(MYDIR, 'README.rst')) as fp:
96+
with open(os.path.join(MYDIR, "README.rst")) as fp:
9197
long_description = fp.read()
9298

9399
# define distribution
94100
setup_args = dict(
95-
name = 'diffpy.pdfgui',
96-
version='3.0.5',
97-
packages = find_packages(os.path.join(MYDIR, 'src')),
98-
package_dir = {'' : 'src'},
99-
include_package_data = True,
100-
test_suite = 'diffpy.pdfgui.tests',
101-
entry_points = {
102-
'gui_scripts': [
103-
'pdfgui=diffpy.pdfgui.applications.pdfgui:main',
101+
name="diffpy.pdfgui",
102+
version="3.0.5",
103+
packages=find_packages(os.path.join(MYDIR, "src")),
104+
package_dir={"": "src"},
105+
include_package_data=True,
106+
test_suite="diffpy.pdfgui.tests",
107+
entry_points={
108+
"gui_scripts": [
109+
"pdfgui=diffpy.pdfgui.applications.pdfgui:main",
104110
],
105111
},
106-
data_files = [
107-
('icons', dirglob('icons', '*.png', '*.ico')),
108-
('doc', dirglob('doc', '*.pdf')),
109-
('doc/manual', dirglob('doc/manual', '*.html', '*.pdf')),
110-
('doc/manual/images', dirglob('doc/manual/images', '*.png')),
111-
('doc/tutorial', dirglob('doc/tutorial', '*')),
112+
data_files=[
113+
("icons", dirglob("icons", "*.png", "*.ico")),
114+
("doc", dirglob("doc", "*.pdf")),
115+
("doc/manual", dirglob("doc/manual", "*.html", "*.pdf")),
116+
("doc/manual/images", dirglob("doc/manual/images", "*.png")),
117+
("doc/tutorial", dirglob("doc/tutorial", "*")),
112118
],
113119
# manual and tutorial files should not be zipped
114-
zip_safe = False,
115-
install_requires = [
116-
'six',
117-
'diffpy.structure>=3',
118-
'diffpy.pdffit2',
119-
'diffpy.utils',
120+
zip_safe=False,
121+
install_requires=[
122+
"six",
123+
"diffpy.structure>=3",
124+
"diffpy.pdffit2",
125+
"diffpy.utils",
120126
],
121-
122-
author = 'Simon J.L. Billinge',
123-
author_email = '[email protected]',
124-
maintainer = 'Pavol Juhas',
125-
maintainer_email = '[email protected]',
126-
url = 'https://github.com/diffpy/diffpy.pdfgui',
127-
description = "GUI for PDF simulation and structure refinement.",
128-
long_description = long_description,
129-
long_description_content_type = 'text/x-rst',
130-
license = 'BSD',
131-
keywords = 'PDF structure refinement GUI',
132-
classifiers = [
127+
author="Simon J.L. Billinge",
128+
author_email="[email protected]",
129+
maintainer="Pavol Juhas",
130+
maintainer_email="[email protected]",
131+
url="https://github.com/diffpy/diffpy.pdfgui",
132+
description="GUI for PDF simulation and structure refinement.",
133+
long_description=long_description,
134+
long_description_content_type="text/x-rst",
135+
license="BSD",
136+
keywords="PDF structure refinement GUI",
137+
classifiers=[
133138
# List of possible values at
134139
# http://pypi.python.org/pypi?:action=list_classifiers
135-
'Development Status :: 5 - Production/Stable',
136-
'Environment :: MacOS X',
137-
'Environment :: Win32 (MS Windows)',
138-
'Environment :: X11 Applications',
139-
'Intended Audience :: Science/Research',
140-
'License :: OSI Approved :: BSD License',
141-
'Operating System :: MacOS',
142-
'Operating System :: Microsoft :: Windows',
143-
'Operating System :: POSIX',
144-
'Programming Language :: Python :: 2.7',
145-
'Programming Language :: Python :: 3.7',
146-
'Programming Language :: Python :: 3.8',
147-
'Programming Language :: Python :: 3.9',
148-
'Programming Language :: Python :: 3.10',
149-
'Programming Language :: Python :: 3.10',
150-
'Topic :: Scientific/Engineering :: Chemistry',
151-
'Topic :: Scientific/Engineering :: Physics',
140+
"Development Status :: 5 - Production/Stable",
141+
"Environment :: MacOS X",
142+
"Environment :: Win32 (MS Windows)",
143+
"Environment :: X11 Applications",
144+
"Intended Audience :: Science/Research",
145+
"License :: OSI Approved :: BSD License",
146+
"Operating System :: MacOS",
147+
"Operating System :: Microsoft :: Windows",
148+
"Operating System :: POSIX",
149+
"Programming Language :: Python :: 2.7",
150+
"Programming Language :: Python :: 3.7",
151+
"Programming Language :: Python :: 3.8",
152+
"Programming Language :: Python :: 3.9",
153+
"Programming Language :: Python :: 3.10",
154+
"Programming Language :: Python :: 3.10",
155+
"Topic :: Scientific/Engineering :: Chemistry",
156+
"Topic :: Scientific/Engineering :: Physics",
152157
],
153158
)
154159

155-
if __name__ == '__main__':
160+
if __name__ == "__main__":
156161
setup(**setup_args)
157162

158163
# End of file

Diff for: src/diffpy/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121

2222
from pkgutil import extend_path
23+
2324
__path__ = extend_path(__path__, __name__)
2425

2526

Diff for: src/diffpy/pdfgui/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
#
1414
##############################################################################
1515

16-
'''Constants:
16+
"""Constants:
1717
__version__ -- full version of this PDFgui release
18-
'''
18+
"""
1919

2020

2121
from diffpy.pdfgui.version import __version__

Diff for: src/diffpy/pdfgui/applications/pdfgui.py

+15-12
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@
4040

4141

4242
def usage():
43-
"""Show usage info.
44-
"""
43+
"""Show usage info."""
4544
myname = os.path.basename(sys.argv[0])
4645
msg = __doc__.replace("pdfgui", myname)
4746
print(msg)
@@ -50,12 +49,13 @@ def usage():
5049

5150
def version():
5251
from diffpy.pdfgui import __version__
52+
5353
print("PDFgui", __version__)
5454
return
5555

5656

5757
def processArguments(argv1):
58-
'''Process command line arguments and store results in pdfguiglobals.
58+
"""Process command line arguments and store results in pdfguiglobals.
5959
This method updates cmdopts, cmdargs and dbopts attributes in the
6060
pdfguiglobals module.
6161
@@ -66,13 +66,13 @@ def processArguments(argv1):
6666
Raises GetoptError for invalid options.
6767
Raises ValueError for more than one project file arguments or
6868
when project is not a valid file.
69-
'''
69+
"""
7070
from diffpy.pdfgui.gui import pdfguiglobals
71+
7172
dbopts = pdfguiglobals.dbopts
72-
dboptions = [('db-' + o[0]) for o in dbopts.alldebugoptions]
73+
dboptions = [("db-" + o[0]) for o in dbopts.alldebugoptions]
7374
# default parameters
74-
opts, args = getopt.gnu_getopt(sys.argv[1:], "hV",
75-
["help", "version"] + dboptions)
75+
opts, args = getopt.gnu_getopt(sys.argv[1:], "hV", ["help", "version"] + dboptions)
7676
# process options
7777
proceed = True
7878
for o, a in opts:
@@ -82,13 +82,14 @@ def processArguments(argv1):
8282
elif o in ("-V", "--version"):
8383
version()
8484
proceed = False
85-
elif o.startswith('--') and o[2:] in dboptions:
85+
elif o.startswith("--") and o[2:] in dboptions:
8686
# strip "--db-"
8787
dbo = o[5:]
8888
setattr(dbopts, dbo, True)
8989
pdfguiglobals.cmdopts = opts
9090
# bail-out here if options contain --help or --version
91-
if not proceed: return False
91+
if not proceed:
92+
return False
9293
# otherwise continue checking arguments
9394
if len(args) == 1 and not os.path.isfile(args[0]):
9495
emsg = "Project file %s does not exist." % args[0]
@@ -102,8 +103,7 @@ def processArguments(argv1):
102103

103104

104105
def main():
105-
'''Main entry point to PDFgui.
106-
'''
106+
"""Main entry point to PDFgui."""
107107
# process arguments
108108
proceed = False
109109
try:
@@ -112,12 +112,15 @@ def main():
112112
print(err, file=sys.stderr)
113113
sys.exit(1)
114114
# bail out when no gui is needed
115-
if not proceed: sys.exit()
115+
if not proceed:
116+
sys.exit()
116117
# initialize gui
117118
import diffpy.pdfgui.gui.main as guimain
119+
118120
# Catch control errors, that may happen during project
119121
# loading, before the GUI gets running
120122
from diffpy.pdfgui.control.controlerrors import ControlError
123+
121124
try:
122125
guimain.main()
123126
except ControlError as err:

0 commit comments

Comments
 (0)