Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
src/sage/sets/set_from_iterator.py: Remove use of SAGE_LIB
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed May 8, 2022
1 parent c8a5bdf commit cce5385
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/sage/sets/set_from_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,21 +463,32 @@ def _instancedoc_(self):
...
Calls the PARI "isprime" function.
"""
# Duplicates sage.misc.cachefunc.CachedFunction._instancedoc_
from sage.misc.sageinspect import sage_getsourcelines, sage_getfile, _extract_embedded_position
f = self.f
doc = f.__doc__ or ''
if _extract_embedded_position(doc) is None:
try:
from os.path import normpath, commonprefix
sourcelines = sage_getsourcelines(f)
from sage.env import SAGE_LIB, SAGE_SRC
filename = sage_getfile(f)

# The following is a heuristics to get
# the file name of the cached function
# or method
if filename.startswith(SAGE_SRC):
filename = filename[len(SAGE_SRC):]
elif filename.startswith(SAGE_LIB):
filename = filename[len(SAGE_LIB):]

def directories():
from sage.env import SAGE_SRC
if SAGE_SRC:
yield normpath(os.path.join(SAGE_SRC, 'sage'))
import sage
yield from sage.__path__

for directory in directories():
if commonprefix([filename, directory]) == directory:
filename = os.path.join('sage', relpath(filename, directory))
break

file_info = "File: %s (starting at line %d)\n"%(filename,sourcelines[1])
doc = file_info+doc
except IOError:
Expand Down

0 comments on commit cce5385

Please sign in to comment.