MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / _alias

Function _alias

src_classic/__init__.py:205–240  ·  view source on GitHub ↗
(fitz_class, old, new)

Source from the content-addressed store, hash-verified

203 warnings.showwarning = showthis
204
205 def _alias(fitz_class, old, new):
206 fname = getattr(fitz_class, new)
207 r = str(fitz_class)[1:-1]
208 objname = " ".join(r.split()[:2])
209 objname = objname.replace("fitz_old.fitz_old.", "")
210 objname = objname.replace("fitz_old.utils.", "")
211 if callable(fname):
212
213 def deprecated_function(*args, **kw):
214 msg = "'%s' removed from %s after v1.19 - use '%s'." % (
215 old,
216 objname,
217 new,
218 )
219 if not VersionBind.startswith("1.18"):
220 warnings.warn(msg, category=FitzDeprecation)
221 return fname(*args, **kw)
222
223 setattr(fitz_class, old, deprecated_function)
224 else:
225 if type(fname) is property:
226 setattr(fitz_class, old, property(fname.fget))
227 else:
228 setattr(fitz_class, old, fname)
229
230 eigen = getattr(fitz_class, old)
231 x = fname.__doc__
232 if not x:
233 x = ""
234 try:
235 if callable(fname) or type(fname) is property:
236 eigen.__doc__ = (
237 "*** Deprecated and removed after v1.19 - use '%s'. ***\n" % new + x
238 )
239 except:
240 pass
241
242 # deprecated Document aliases
243 _alias(fitz_old.Document, "chapterCount", "chapter_count")

Callers 1

restore_aliasesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…