diffpy.structure 3.4.0rc0__tar.gz → 3.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/LICENSE-DANSE.rst +1 -4
  2. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/LICENSE.rst +3 -0
  3. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/PKG-INFO +3 -3
  4. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/README.rst +2 -2
  5. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/__init__.py +26 -7
  6. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/_legacy_importer.py +0 -1
  7. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/apps/anyeye.py +102 -15
  8. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/apps/transtru.py +8 -8
  9. diffpy_structure-3.5.0/src/diffpy/structure/apps/vesta_viewer.py +367 -0
  10. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/atom.py +94 -61
  11. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/expansion/makeellipsoid.py +46 -10
  12. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/expansion/shapeutils.py +22 -0
  13. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/expansion/supercell_mod.py +1 -1
  14. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/lattice.py +73 -15
  15. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/parsers/__init__.py +57 -5
  16. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/parsers/p_auto.py +67 -13
  17. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/parsers/p_cif.py +159 -71
  18. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/parsers/p_discus.py +137 -16
  19. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/parsers/p_pdb.py +102 -12
  20. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/parsers/p_pdffit.py +42 -6
  21. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/parsers/p_rawxyz.py +54 -2
  22. diffpy_structure-3.5.0/src/diffpy/structure/parsers/p_vesta.py +367 -0
  23. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/parsers/p_xcfg.py +60 -8
  24. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/parsers/p_xyz.py +54 -2
  25. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/parsers/parser_index_mod.py +3 -3
  26. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/parsers/structureparser.py +56 -6
  27. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/pdffitstructure.py +25 -6
  28. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/sgtbxspacegroups.py +1 -2
  29. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/spacegroupmod.py +0 -1
  30. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/spacegroups.py +79 -12
  31. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/structure.py +418 -103
  32. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/structureerrors.py +2 -0
  33. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/symmetryutilities.py +413 -85
  34. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/utils.py +26 -6
  35. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy.structure.egg-info/PKG-INFO +3 -3
  36. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy.structure.egg-info/SOURCES.txt +4 -0
  37. diffpy_structure-3.5.0/tests/test_atom.py +304 -0
  38. diffpy_structure-3.5.0/tests/test_expansion.py +123 -0
  39. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/test_lattice.py +68 -13
  40. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/test_loadstructure.py +33 -7
  41. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/test_p_cif.py +129 -16
  42. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/test_p_discus.py +11 -11
  43. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/test_p_pdffit.py +13 -13
  44. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/test_parsers.py +7 -7
  45. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/test_spacegroups.py +57 -12
  46. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/test_structure.py +406 -65
  47. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/test_supercell.py +2 -2
  48. diffpy_structure-3.5.0/tests/test_symmetryutilities.py +1288 -0
  49. diffpy_structure-3.5.0/tests/test_utils.py +38 -0
  50. diffpy_structure-3.4.0rc0/tests/test_atom.py +0 -152
  51. diffpy_structure-3.4.0rc0/tests/test_symmetryutilities.py +0 -615
  52. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/AUTHORS.rst +0 -0
  53. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/LICENSE-pymmlib.rst +0 -0
  54. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/MANIFEST.in +0 -0
  55. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/pyproject.toml +0 -0
  56. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/requirements/build.txt +0 -0
  57. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/requirements/conda.txt +0 -0
  58. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/requirements/docs.txt +0 -0
  59. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/requirements/pip.txt +0 -0
  60. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/requirements/tests.txt +0 -0
  61. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/setup.cfg +0 -0
  62. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/__init__.py +0 -0
  63. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/apps/__init__.py +0 -0
  64. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/expansion/__init__.py +0 -0
  65. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/mmlibspacegroups.py +0 -0
  66. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/structure_app.py +0 -0
  67. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy/structure/version.py +0 -0
  68. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy.structure.egg-info/dependency_links.txt +0 -0
  69. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy.structure.egg-info/entry_points.txt +0 -0
  70. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy.structure.egg-info/requires.txt +0 -0
  71. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/src/diffpy.structure.egg-info/top_level.txt +0 -0
  72. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/conftest.py +0 -0
  73. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/test_version.py +0 -0
  74. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/BubbleRaftShort.xcfg +0 -0
  75. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/CdSe_bulk.stru +0 -0
  76. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/LiCl-bad.cif +0 -0
  77. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/Ni-bad.stru +0 -0
  78. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/Ni-discus.stru +0 -0
  79. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/Ni.stru +0 -0
  80. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/Ni_prim123.stru +0 -0
  81. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/Ni_ref.cif +0 -0
  82. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/PbTe.cif +0 -0
  83. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/TeI-unkocc.cif +0 -0
  84. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/TeI.cif +0 -0
  85. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/ZnSb_RT_Q28X_VM_20_fxiso.rstr +0 -0
  86. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/arginine.pdb +0 -0
  87. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/badspacegroup.cif +0 -0
  88. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/bucky-bad1.xyz +0 -0
  89. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/bucky-bad2.xyz +0 -0
  90. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/bucky-plain-bad.xyz +0 -0
  91. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/bucky-plain.xyz +0 -0
  92. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/bucky-raw.xyz +0 -0
  93. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/bucky.xyz +0 -0
  94. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/curlybrackets.cif +0 -0
  95. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/customsg.cif +0 -0
  96. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/graphite.cif +0 -0
  97. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/hexagon-raw-bad.xyz +0 -0
  98. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/hexagon-raw.xy +0 -0
  99. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/hexagon-raw.xyz +0 -0
  100. {diffpy_structure-3.4.0rc0 → diffpy_structure-3.5.0}/tests/testdata/nosites.cif +0 -0
@@ -9,14 +9,11 @@ Copyright 2006-2007, Board of Trustees of Michigan State University,
9
9
  Copyright 2008-2012, The Trustees of Columbia University in the
10
10
  City of New York. (Copyright holder indicated in each source file).
11
11
 
12
- Copyright (c) 2024, The Trustees of Columbia University in the City of New York.
13
- All rights reserved.
14
-
15
12
  For more information please visit the project web-page:
16
13
 
17
14
  http://www.diffpy.org/
18
15
 
19
- or email Prof. Simon Billinge at sb2896@columbia.edu
16
+ or email Prof. Simon Billinge at sbillinge@ucsb.edu
20
17
 
21
18
  Redistribution and use in source and binary forms, with or without
22
19
  modification, are permitted provided that the following conditions
@@ -18,6 +18,9 @@ Copyright (c) 2014-2019, Brookhaven Science Associates, Brookhaven National Labo
18
18
  Copyright (c) 2024-2025, The Trustees of Columbia University in the City of New York.
19
19
  All rights reserved.
20
20
 
21
+ Copyright (c) 2026-present, The Contributors to the diffpy.structure project.
22
+ All rights reserved.
23
+
21
24
  The "DiffPy-CMI" is distributed subject to the following license conditions:
22
25
 
23
26
  .. code-block:: text
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: diffpy.structure
3
- Version: 3.4.0rc0
3
+ Version: 3.5.0
4
4
  Summary: Crystal structure container and parsers for structure formats.
5
5
  Author-email: Simon Billinge <sbillinge@ucsb.edu>
6
6
  Maintainer-email: Simon Billinge <sbillinge@ucsb.edu>
@@ -49,8 +49,8 @@ Dynamic: license-file
49
49
  .. |Black| image:: https://img.shields.io/badge/code_style-black-black
50
50
  :target: https://github.com/psf/black
51
51
 
52
- .. |CI| image:: https://github.com/diffpy/diffpy.structure/actions/workflows/matrix-and-codecov-on-merge-to-main.yml/badge.svg
53
- :target: https://github.com/diffpy/diffpy.structure/actions/workflows/matrix-and-codecov-on-merge-to-main.yml
52
+ .. |CI| image:: https://github.com/diffpy/diffpy.structure/actions/workflows/matrix-and-codecov.yml/badge.svg
53
+ :target: https://github.com/diffpy/diffpy.structure/actions/workflows/matrix-and-codecov.yml
54
54
 
55
55
  .. |Codecov| image:: https://codecov.io/gh/diffpy/diffpy.structure/branch/main/graph/badge.svg
56
56
  :target: https://codecov.io/gh/diffpy/diffpy.structure
@@ -15,8 +15,8 @@
15
15
  .. |Black| image:: https://img.shields.io/badge/code_style-black-black
16
16
  :target: https://github.com/psf/black
17
17
 
18
- .. |CI| image:: https://github.com/diffpy/diffpy.structure/actions/workflows/matrix-and-codecov-on-merge-to-main.yml/badge.svg
19
- :target: https://github.com/diffpy/diffpy.structure/actions/workflows/matrix-and-codecov-on-merge-to-main.yml
18
+ .. |CI| image:: https://github.com/diffpy/diffpy.structure/actions/workflows/matrix-and-codecov.yml/badge.svg
19
+ :target: https://github.com/diffpy/diffpy.structure/actions/workflows/matrix-and-codecov.yml
20
20
 
21
21
  .. |Codecov| image:: https://codecov.io/gh/diffpy/diffpy.structure/branch/main/graph/badge.svg
22
22
  :target: https://codecov.io/gh/diffpy/diffpy.structure
@@ -33,21 +33,30 @@ Exceptions:
33
33
  * SymmetryError
34
34
  """
35
35
 
36
-
36
+ import os
37
37
  import sys
38
38
 
39
39
  import diffpy.structure as _structure
40
40
  from diffpy.structure.atom import Atom
41
41
  from diffpy.structure.lattice import Lattice
42
- from diffpy.structure.parsers import getParser
42
+ from diffpy.structure.parsers import get_parser
43
43
  from diffpy.structure.pdffitstructure import PDFFitStructure
44
44
  from diffpy.structure.structure import Structure
45
45
  from diffpy.structure.structureerrors import LatticeError, StructureFormatError, SymmetryError
46
46
 
47
47
  # package version
48
48
  from diffpy.structure.version import __version__
49
+ from diffpy.utils._deprecator import build_deprecation_message, deprecated
49
50
 
50
51
  # Deprecations -------------------------------------------------------
52
+ base = "diffpy.structure"
53
+ removal_version = "4.0.0"
54
+ loadStructure_deprecation_msg = build_deprecation_message(
55
+ base,
56
+ "loadStructure",
57
+ "load_structure",
58
+ removal_version,
59
+ )
51
60
 
52
61
 
53
62
  # @deprecated
@@ -72,7 +81,17 @@ sys.modules["diffpy.Structure"] = DeprecatedStructureModule()
72
81
  # top level routines
73
82
 
74
83
 
84
+ @deprecated(loadStructure_deprecation_msg)
75
85
  def loadStructure(filename, fmt="auto", **kw):
86
+ """This function has been deprecated and will be removed in version
87
+ 4.0.0.
88
+
89
+ Please use diffpy.structure.load_structure instead.
90
+ """
91
+ return load_structure(filename, fmt, **kw)
92
+
93
+
94
+ def load_structure(filename, fmt="auto", **kw):
76
95
  """Load new structure object from the specified file.
77
96
 
78
97
  Parameters
@@ -82,10 +101,10 @@ def loadStructure(filename, fmt="auto", **kw):
82
101
  Path to the file to be loaded.
83
102
  fmt : str, Optional
84
103
  Format of the structure file such as 'cif' or 'xyz'. Must be
85
- one of the formats listed by the `parsers.inputFormats` function.
104
+ one of the formats listed by the `parsers.input_formats` function.
86
105
  When 'auto', all supported formats are tried in a sequence.
87
106
  kw : Optional
88
- Extra keyword arguments that are passed to `parsers.getParser`
107
+ Extra keyword arguments that are passed to `parsers.get_parser`
89
108
  function. These configure the dedicated Parser object that
90
109
  is used to read content in filename.
91
110
 
@@ -96,9 +115,9 @@ def loadStructure(filename, fmt="auto", **kw):
96
115
  Return a more specific PDFFitStructure type for 'pdffit'
97
116
  and 'discus' formats.
98
117
  """
99
-
100
- p = getParser(fmt, **kw)
101
- rv = p.parseFile(filename)
118
+ filename = os.fspath(filename)
119
+ p = get_parser(fmt, **kw)
120
+ rv = p.parse_file(filename)
102
121
  return rv
103
122
 
104
123
 
@@ -27,7 +27,6 @@ Warning
27
27
  This module is deprecated and will be removed in the future.
28
28
  """
29
29
 
30
-
31
30
  import importlib.abc
32
31
  import sys
33
32
  from warnings import warn
@@ -52,6 +52,46 @@ import signal
52
52
  import sys
53
53
 
54
54
  from diffpy.structure.structureerrors import StructureFormatError
55
+ from diffpy.utils._deprecator import build_deprecation_message, deprecated
56
+
57
+ base = "diffpy.structure"
58
+ removal_version = "4.0.0"
59
+ loadStructureFile_deprecation_msg = build_deprecation_message(
60
+ base,
61
+ "loadStructureFile",
62
+ "load_structure_file",
63
+ removal_version,
64
+ )
65
+ convertStructureFile_deprecation_msg = build_deprecation_message(
66
+ base,
67
+ "loadStructureFile",
68
+ "load_structure_file",
69
+ removal_version,
70
+ )
71
+ watchStructureFile_deprecation_msg = build_deprecation_message(
72
+ base,
73
+ "watchStructureFile",
74
+ "watch_structure_file",
75
+ removal_version,
76
+ )
77
+ cleanUp_deprecation_msg = build_deprecation_message(
78
+ base,
79
+ "cleanUp",
80
+ "clean_up",
81
+ removal_version,
82
+ )
83
+ parseFormula_deprecation_msg = build_deprecation_message(
84
+ base,
85
+ "parseFormula",
86
+ "parse_formula",
87
+ removal_version,
88
+ )
89
+ signalHandler_deprecation_msg = build_deprecation_message(
90
+ base,
91
+ "signalHandler",
92
+ "signal_handler",
93
+ removal_version,
94
+ )
55
95
 
56
96
  # parameter dictionary
57
97
  pd = {
@@ -72,9 +112,9 @@ def usage(style=None):
72
112
  if style == "brief":
73
113
  msg = msg.split("\n")[1] + "\n" + "Try `%s --help' for more information." % myname
74
114
  else:
75
- from diffpy.structure.parsers import inputFormats
115
+ from diffpy.structure.parsers import input_formats
76
116
 
77
- fmts = [f for f in inputFormats() if f != "auto"]
117
+ fmts = [f for f in input_formats() if f != "auto"]
78
118
  msg = msg.replace("inputFormats", " ".join(fmts))
79
119
  print(msg)
80
120
  return
@@ -87,9 +127,28 @@ def version():
87
127
  return
88
128
 
89
129
 
130
+ @deprecated(loadStructureFile_deprecation_msg)
90
131
  def loadStructureFile(filename, format="auto"):
91
132
  """Load structure from specified file.
92
133
 
134
+ Parameters
135
+ ----------
136
+ filename : str
137
+ Path to the structure file.
138
+ format : str, Optional
139
+ File format, by default "auto".
140
+
141
+ Returns
142
+ -------
143
+ tuple
144
+ A tuple of (Structure, fileformat).
145
+ """
146
+ return load_structure_file(filename, format)
147
+
148
+
149
+ def load_structure_file(filename, format="auto"):
150
+ """Load structure from specified file.
151
+
93
152
  Parameters
94
153
  ----------
95
154
  filename : str
@@ -110,7 +169,12 @@ def loadStructureFile(filename, format="auto"):
110
169
  return (stru, fileformat)
111
170
 
112
171
 
172
+ @deprecated(convertStructureFile_deprecation_msg)
113
173
  def convertStructureFile(pd):
174
+ return convert_structure_file(pd)
175
+
176
+
177
+ def convert_structure_file(pd):
114
178
  # make temporary directory on the first pass
115
179
  if "tmpdir" not in pd:
116
180
  from tempfile import mkdtemp
@@ -123,7 +187,7 @@ def convertStructureFile(pd):
123
187
  fmt = pd.get("format", "auto")
124
188
  stru = None
125
189
  if fmt == "auto":
126
- stru, fmt = loadStructureFile(strufile)
190
+ stru, fmt = load_structure_file(strufile)
127
191
  pd["fmt"] = fmt
128
192
  # if fmt is recognized by the viewer, use as is
129
193
  if fmt in pd["formats"] and pd["formula"] is None:
@@ -134,7 +198,7 @@ def convertStructureFile(pd):
134
198
  return
135
199
  # otherwise convert to the first recognized viewer format
136
200
  if stru is None:
137
- stru = loadStructureFile(strufile, fmt)[0]
201
+ stru = load_structure_file(strufile, fmt)[0]
138
202
  if pd["formula"]:
139
203
  formula = pd["formula"]
140
204
  if len(formula) != len(stru):
@@ -154,19 +218,29 @@ def convertStructureFile(pd):
154
218
  return
155
219
 
156
220
 
221
+ @deprecated(watchStructureFile_deprecation_msg)
157
222
  def watchStructureFile(pd):
223
+ return watch_structure_file(pd)
224
+
225
+
226
+ def watch_structure_file(pd):
158
227
  from time import sleep
159
228
 
160
229
  strufile = pd["strufile"]
161
230
  tmpfile = pd["tmpfile"]
162
231
  while pd["watch"]:
163
232
  if os.path.getmtime(tmpfile) < os.path.getmtime(strufile):
164
- convertStructureFile(pd)
233
+ convert_structure_file(pd)
165
234
  sleep(1)
166
235
  return
167
236
 
168
237
 
238
+ @deprecated(cleanUp_deprecation_msg)
169
239
  def cleanUp(pd):
240
+ return clean_up(pd)
241
+
242
+
243
+ def clean_up(pd):
170
244
  if "tmpfile" in pd:
171
245
  os.remove(pd["tmpfile"])
172
246
  del pd["tmpfile"]
@@ -176,7 +250,14 @@ def cleanUp(pd):
176
250
  return
177
251
 
178
252
 
253
+ @deprecated(parseFormula_deprecation_msg)
179
254
  def parseFormula(formula):
255
+ """Parse chemical formula and return a list of elements."""
256
+ # remove all blanks
257
+ return parse_formula(formula)
258
+
259
+
260
+ def parse_formula(formula):
180
261
  """Parse chemical formula and return a list of elements."""
181
262
  # remove all blanks
182
263
  formula = re.sub(r"\s", "", formula)
@@ -197,11 +278,17 @@ def parseFormula(formula):
197
278
 
198
279
 
199
280
  def die(exit_status=0, pd={}):
200
- cleanUp(pd)
281
+ clean_up(pd)
201
282
  sys.exit(exit_status)
202
283
 
203
284
 
285
+ @deprecated(signalHandler_deprecation_msg)
204
286
  def signalHandler(signum, stackframe):
287
+ # revert to default handler
288
+ return signal_handler(signum, stackframe)
289
+
290
+
291
+ def signal_handler(signum, stackframe):
205
292
  # revert to default handler
206
293
  signal.signal(signum, signal.SIG_DFL)
207
294
  if signum == signal.SIGCHLD:
@@ -231,7 +318,7 @@ def main():
231
318
  for o, a in opts:
232
319
  if o in ("-f", "--formula"):
233
320
  try:
234
- pd["formula"] = parseFormula(a)
321
+ pd["formula"] = parse_formula(a)
235
322
  except RuntimeError as msg:
236
323
  print(msg, file=sys.stderr)
237
324
  die(2)
@@ -255,23 +342,23 @@ def main():
255
342
  die(2)
256
343
  pd["strufile"] = args[0]
257
344
  # trap the following signals
258
- signal.signal(signal.SIGHUP, signalHandler)
259
- signal.signal(signal.SIGQUIT, signalHandler)
260
- signal.signal(signal.SIGSEGV, signalHandler)
261
- signal.signal(signal.SIGTERM, signalHandler)
262
- signal.signal(signal.SIGINT, signalHandler)
345
+ signal.signal(signal.SIGHUP, signal_handler)
346
+ signal.signal(signal.SIGQUIT, signal_handler)
347
+ signal.signal(signal.SIGSEGV, signal_handler)
348
+ signal.signal(signal.SIGTERM, signal_handler)
349
+ signal.signal(signal.SIGINT, signal_handler)
263
350
  env = os.environ.copy()
264
351
  if os.path.basename(pd["viewer"]).startswith("atomeye"):
265
352
  env["XLIB_SKIP_ARGB_VISUALS"] = "1"
266
353
  # try to run the thing:
267
354
  try:
268
- convertStructureFile(pd)
355
+ convert_structure_file(pd)
269
356
  spawnargs = (pd["viewer"], pd["viewer"], pd["tmpfile"], env)
270
357
  # load strufile in atomeye
271
358
  if pd["watch"]:
272
- signal.signal(signal.SIGCHLD, signalHandler)
359
+ signal.signal(signal.SIGCHLD, signal_handler)
273
360
  os.spawnlpe(os.P_NOWAIT, *spawnargs)
274
- watchStructureFile(pd)
361
+ watch_structure_file(pd)
275
362
  else:
276
363
  status = os.spawnlpe(os.P_WAIT, *spawnargs)
277
364
  die(status, pd)
@@ -52,10 +52,10 @@ def usage(style=None):
52
52
  if style == "brief":
53
53
  msg = msg.split("\n")[1] + "\n" + "Try `%s --help' for more information." % myname
54
54
  else:
55
- from diffpy.structure.parsers import inputFormats, outputFormats
55
+ from diffpy.structure.parsers import input_formats, output_formats
56
56
 
57
- msg = msg.replace("inputFormats", " ".join(inputFormats()))
58
- msg = msg.replace("outputFormats", " ".join(outputFormats()))
57
+ msg = msg.replace("inputFormats", " ".join(input_formats()))
58
+ msg = msg.replace("outputFormats", " ".join(output_formats()))
59
59
  print(msg)
60
60
  return
61
61
 
@@ -88,14 +88,14 @@ def main():
88
88
  usage("brief")
89
89
  sys.exit()
90
90
  # process arguments
91
- from diffpy.structure.parsers import inputFormats, outputFormats
91
+ from diffpy.structure.parsers import input_formats, output_formats
92
92
 
93
93
  try:
94
94
  infmt, outfmt = args[0].split("..", 1)
95
- if infmt not in inputFormats():
95
+ if infmt not in input_formats():
96
96
  print("'%s' is not valid input format" % infmt, file=sys.stderr)
97
97
  sys.exit(2)
98
- if outfmt not in outputFormats():
98
+ if outfmt not in output_formats():
99
99
  print("'%s' is not valid output format" % outfmt, file=sys.stderr)
100
100
  sys.exit(2)
101
101
  except ValueError:
@@ -109,10 +109,10 @@ def main():
109
109
  strufile = args[1]
110
110
  stru = Structure()
111
111
  if args[1] == "-":
112
- stru.readStr(sys.stdin.read(), infmt)
112
+ stru.read_structure(sys.stdin.read(), infmt)
113
113
  else:
114
114
  stru.read(strufile, infmt)
115
- sys.stdout.write(stru.writeStr(outfmt))
115
+ sys.stdout.write(stru.write_structure(outfmt))
116
116
  except IndexError:
117
117
  print("strufile not specified", file=sys.stderr)
118
118
  sys.exit(2)