MCPcopy Index your code
hub / github.com/pymupdf/PyMuPDF / __init__

Method __init__

src/__init__.py:8901–8999  ·  view source on GitHub ↗
(self, obj, rlink, document=None)

Source from the content-addressed store, hash-verified

8899 """link or outline destination details"""
8900
8901 def __init__(self, obj, rlink, document=None):
8902 isExt = obj.is_external
8903 isInt = not isExt
8904 self.dest = ""
8905 self.file_spec = ""
8906 self.flags = 0
8907 self.is_map = False
8908 self.is_uri = False
8909 self.kind = LINK_NONE
8910 self.lt = Point(0, 0)
8911 self.named = dict()
8912 self.new_window = ""
8913 self.page = obj.page
8914 self.rb = Point(0, 0)
8915 self.uri = obj.uri
8916
8917 def uri_to_dict(uri):
8918 items = self.uri[1:].split('&')
8919 ret = dict()
8920 for item in items:
8921 eq = item.find('=')
8922 if eq >= 0:
8923 ret[item[:eq]] = item[eq+1:]
8924 else:
8925 ret[item] = None
8926 return ret
8927
8928 def unescape(name):
8929 """Unescape '%AB' substrings to chr(0xAB)."""
8930 split = name.replace("%%", "%25") # take care of escaped '%'
8931 split = split.split("%")
8932 newname = split[0]
8933 for item in split[1:]:
8934 piece = item[:2]
8935 newname += chr(int(piece, base=16))
8936 newname += item[2:]
8937 return newname
8938
8939 if rlink and not self.uri.startswith("#"):
8940 self.uri = f"#page={rlink[0] + 1}&zoom=0,{_format_g(rlink[1])},{_format_g(rlink[2])}"
8941 if obj.is_external:
8942 self.page = -1
8943 self.kind = LINK_URI
8944 if not self.uri:
8945 self.page = -1
8946 self.kind = LINK_NONE
8947 if isInt and self.uri:
8948 self.uri = self.uri.replace("&zoom=nan", "&zoom=0")
8949 if self.uri.startswith("#"):
8950 self.kind = LINK_GOTO
8951 m = re.match('^#page=([0-9]+)&zoom=([0-9.]+),(-?[0-9.]+),(-?[0-9.]+)$', self.uri)
8952 if m:
8953 self.page = int(m.group(1)) - 1
8954 self.lt = Point(float((m.group(3))), float(m.group(4)))
8955 self.flags = self.flags | LINK_FLAG_L_VALID | LINK_FLAG_T_VALID
8956 else:
8957 m = re.match('^#page=([0-9]+)$', self.uri)
8958 if m:

Callers

nothing calls this directly

Calls 4

PointClass · 0.85
_format_gFunction · 0.85
resolve_namesMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected