Skip to content

Commit de843cf

Browse files
committed
deprecate PDFParser
1 parent 6012bb2 commit de843cf

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/diffpy/srfit/pdf/pdfparser.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@
2828

2929
from diffpy.srfit.exceptions import ParseError
3030
from diffpy.srfit.fitbase.profileparser import ProfileParser
31+
from diffpy.utils._deprecator import build_deprecation_message, deprecated
32+
33+
removal_verison = "4.0.0"
34+
base = "diffpy.srfit.pdf.pdfparser.PDFParser"
35+
new_base = "diffpy.srfit.fitbase.ProfileParser"
36+
37+
parseFile_dep_msg = build_deprecation_message(
38+
base,
39+
"parseFile",
40+
"parse_file",
41+
removal_version=removal_verison,
42+
new_base=new_base,
43+
)
3144

3245

3346
class PDFParser(ProfileParser):
@@ -106,6 +119,11 @@ class PDFParser(ProfileParser):
106119

107120
_format = "PDF"
108121

122+
# Marking this function as deprecated because PDFParser.parseFile calls it
123+
# so when people use PDFParser.parseFile, they will get a
124+
# warning that it is deprecated and they should use
125+
# ProfileParser.parse_file instead.
126+
@deprecated(parseFile_dep_msg)
109127
def parseString(self, patstring):
110128
"""Parse a string and set the _x, _y, _dx, _dy and _meta
111129
variables.
@@ -121,6 +139,7 @@ def parseString(self, patstring):
121139
122140
Raises ParseError if the string cannot be parsed
123141
"""
142+
124143
# useful regex patterns:
125144
rx = {"f": r"[-+]?(\d+(\.\d*)?|\d*\.\d+)([eE][-+]?\d+)?"}
126145
# find where does the data start

0 commit comments

Comments
 (0)