nwo
stringlengths
10
28
sha
stringlengths
40
40
path
stringlengths
11
97
identifier
stringlengths
1
64
parameters
stringlengths
2
2.24k
return_statement
stringlengths
0
2.17k
docstring
stringlengths
0
5.45k
docstring_summary
stringlengths
0
3.83k
func_begin
int64
1
13.4k
func_end
int64
2
13.4k
function
stringlengths
28
56.4k
url
stringlengths
106
209
project
int64
1
48
executed_lines
list
executed_lines_pc
float64
0
153
missing_lines
list
missing_lines_pc
float64
0
100
covered
bool
2 classes
filecoverage
float64
2.53
100
function_lines
int64
2
1.46k
mccabe
int64
1
253
coverage
float64
0
100
docstring_lines
int64
0
112
function_nodoc
stringlengths
9
56.4k
id
int64
0
29.8k
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
ContentStream.__parse_content_stream
(self, stream: StreamType)
963
991
def __parse_content_stream(self, stream: StreamType) -> None: stream.seek(0, 0) operands: List[Union[int, str, PdfObject]] = [] while True: peek = read_non_whitespace(stream) if peek == b"" or peek == 0: break stream.seek(-1, 1) if peek.isalpha() or peek in (b"'", b'"'): operator = read_until_regex(stream, NameObject.delimiter_pattern, True) if operator == b"BI": # begin inline image - a completely different parsing # mechanism is required, of course... thanks buddy... assert operands == [] ii = self._read_inline_image(stream) self.operations.append((ii, b"INLINE IMAGE")) else: self.operations.append((operands, operator)) operands = [] elif peek == b"%": # If we encounter a comment in the content stream, we have to # handle it here. Typically, read_object will handle # encountering a comment -- but read_object assumes that # following the comment must be the object we're trying to # read. In this case, it could be an operator instead. while peek not in (b"\r", b"\n"): peek = stream.read(1) else: operands.append(read_object(stream, None, self.forced_encoding))
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L963-L991
39
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28 ]
93.103448
[]
0
false
92.337917
29
10
100
0
def __parse_content_stream(self, stream: StreamType) -> None: stream.seek(0, 0) operands: List[Union[int, str, PdfObject]] = [] while True: peek = read_non_whitespace(stream) if peek == b"" or peek == 0: break stream.seek(-1, 1) if peek.isalpha() or peek in (b"'", b'"'): operator = read_until_regex(stream, NameObject.delimiter_pattern, True) if operator == b"BI": # begin inline image - a completely different parsing # mechanism is required, of course... thanks buddy... assert operands == [] ii = self._read_inline_image(stream) self.operations.append((ii, b"INLINE IMAGE")) else: self.operations.append((operands, operator)) operands = [] elif peek == b"%": # If we encounter a comment in the content stream, we have to # handle it here. Typically, read_object will handle # encountering a comment -- but read_object assumes that # following the comment must be the object we're trying to # read. In this case, it could be an operator instead. while peek not in (b"\r", b"\n"): peek = stream.read(1) else: operands.append(read_object(stream, None, self.forced_encoding))
24,654
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
ContentStream._read_inline_image
(self, stream: StreamType)
return {"settings": settings, "data": data.getvalue()}
993
1,069
def _read_inline_image(self, stream: StreamType) -> Dict[str, Any]: # begin reading just after the "BI" - begin image # first read the dictionary of settings. settings = DictionaryObject() while True: tok = read_non_whitespace(stream) stream.seek(-1, 1) if tok == b"I": # "ID" - begin of image data break key = read_object(stream, self.pdf) tok = read_non_whitespace(stream) stream.seek(-1, 1) value = read_object(stream, self.pdf) settings[key] = value # left at beginning of ID tmp = stream.read(3) assert tmp[:2] == b"ID" data = BytesIO() # Read the inline image, while checking for EI (End Image) operator. while True: # Read 8 kB at a time and check if the chunk contains the E operator. buf = stream.read(8192) # We have reached the end of the stream, but haven't found the EI operator. if not buf: raise PdfReadError("Unexpected end of stream") loc = buf.find( b"E" ) # we can not look straight for "EI" because it may not have been loaded in the buffer if loc == -1: data.write(buf) else: # Write out everything before the E. data.write(buf[0:loc]) # Seek back in the stream to read the E next. stream.seek(loc - len(buf), 1) tok = stream.read(1) # E of "EI" # Check for End Image tok2 = stream.read(1) # I of "EI" if tok2 != b"I": stream.seek(-1, 1) data.write(tok) continue # for further debug : print("!!!!",buf[loc-1:loc+10]) info = tok + tok2 tok3 = stream.read( 1 ) # possible space after "EI" may not been loaded in buf if tok3 not in WHITESPACES: stream.seek(-2, 1) # to step back on I data.write(tok) elif buf[loc - 1 : loc] in WHITESPACES: # and tok3 in WHITESPACES: # Data can contain [\s]EI[\s]: 4 chars sufficient, checking Q operator not required. while tok3 in WHITESPACES: # needed ???? : info += tok3 tok3 = stream.read(1) stream.seek(-1, 1) # we do not insert EI break else: # buf[loc - 1 : loc] not in WHITESPACES and tok3 in WHITESPACES: # Data can contain [!\s]EI[\s], so check for Q or EMC operator is required to have 4 chars. while tok3 in WHITESPACES: info += tok3 tok3 = stream.read(1) stream.seek(-1, 1) if tok3 == b"Q": break elif tok3 == b"E": ope = stream.read(3) stream.seek(-3, 1) if ope == b"EMC": break else: data.write(info) return {"settings": settings, "data": data.getvalue()}
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L993-L1069
39
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 75, 76 ]
90.909091
[]
0
false
92.337917
77
15
100
0
def _read_inline_image(self, stream: StreamType) -> Dict[str, Any]: # begin reading just after the "BI" - begin image # first read the dictionary of settings. settings = DictionaryObject() while True: tok = read_non_whitespace(stream) stream.seek(-1, 1) if tok == b"I": # "ID" - begin of image data break key = read_object(stream, self.pdf) tok = read_non_whitespace(stream) stream.seek(-1, 1) value = read_object(stream, self.pdf) settings[key] = value # left at beginning of ID tmp = stream.read(3) assert tmp[:2] == b"ID" data = BytesIO() # Read the inline image, while checking for EI (End Image) operator. while True: # Read 8 kB at a time and check if the chunk contains the E operator. buf = stream.read(8192) # We have reached the end of the stream, but haven't found the EI operator. if not buf: raise PdfReadError("Unexpected end of stream") loc = buf.find( b"E" ) # we can not look straight for "EI" because it may not have been loaded in the buffer if loc == -1: data.write(buf) else: # Write out everything before the E. data.write(buf[0:loc]) # Seek back in the stream to read the E next. stream.seek(loc - len(buf), 1) tok = stream.read(1) # E of "EI" # Check for End Image tok2 = stream.read(1) # I of "EI" if tok2 != b"I": stream.seek(-1, 1) data.write(tok) continue # for further debug : print("!!!!",buf[loc-1:loc+10]) info = tok + tok2 tok3 = stream.read( 1 ) # possible space after "EI" may not been loaded in buf if tok3 not in WHITESPACES: stream.seek(-2, 1) # to step back on I data.write(tok) elif buf[loc - 1 : loc] in WHITESPACES: # and tok3 in WHITESPACES: # Data can contain [\s]EI[\s]: 4 chars sufficient, checking Q operator not required. while tok3 in WHITESPACES: # needed ???? : info += tok3 tok3 = stream.read(1) stream.seek(-1, 1) # we do not insert EI break else: # buf[loc - 1 : loc] not in WHITESPACES and tok3 in WHITESPACES: # Data can contain [!\s]EI[\s], so check for Q or EMC operator is required to have 4 chars. while tok3 in WHITESPACES: info += tok3 tok3 = stream.read(1) stream.seek(-1, 1) if tok3 == b"Q": break elif tok3 == b"E": ope = stream.read(3) stream.seek(-3, 1) if ope == b"EMC": break else: data.write(info) return {"settings": settings, "data": data.getvalue()}
24,655
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
ContentStream._data
(self)
return newdata.getvalue()
1,072
1,089
def _data(self) -> bytes: newdata = BytesIO() for operands, operator in self.operations: if operator == b"INLINE IMAGE": newdata.write(b"BI") dicttext = BytesIO() operands["settings"].write_to_stream(dicttext, None) newdata.write(dicttext.getvalue()[2:-2]) newdata.write(b"ID ") newdata.write(operands["data"]) newdata.write(b"EI") else: for op in operands: op.write_to_stream(newdata, None) newdata.write(b" ") newdata.write(b_(operator)) newdata.write(b"\n") return newdata.getvalue()
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1072-L1089
39
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17 ]
94.444444
[]
0
false
92.337917
18
4
100
0
def _data(self) -> bytes: newdata = BytesIO() for operands, operator in self.operations: if operator == b"INLINE IMAGE": newdata.write(b"BI") dicttext = BytesIO() operands["settings"].write_to_stream(dicttext, None) newdata.write(dicttext.getvalue()[2:-2]) newdata.write(b"ID ") newdata.write(operands["data"]) newdata.write(b"EI") else: for op in operands: op.write_to_stream(newdata, None) newdata.write(b" ") newdata.write(b_(operator)) newdata.write(b"\n") return newdata.getvalue()
24,656
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
ContentStream._data
(self, value: Union[str, bytes])
1,092
1,093
def _data(self, value: Union[str, bytes]) -> None: self.__parse_content_stream(BytesIO(b_(value)))
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1092-L1093
39
[ 0 ]
50
[ 1 ]
50
false
92.337917
2
1
50
0
def _data(self, value: Union[str, bytes]) -> None: self.__parse_content_stream(BytesIO(b_(value)))
24,657
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Field.__init__
(self, data: DictionaryObject)
1,159
1,170
def __init__(self, data: DictionaryObject) -> None: DictionaryObject.__init__(self) field_attributes = ( FieldDictionaryAttributes.attributes() + CheckboxRadioButtonAttributes.attributes() ) self.indirect_reference = data.indirect_reference for attr in field_attributes: try: self[NameObject(attr)] = data[attr] except KeyError: pass
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1159-L1170
39
[ 0, 1, 2, 6, 7, 8, 9, 10, 11 ]
75
[]
0
false
92.337917
12
3
100
0
def __init__(self, data: DictionaryObject) -> None: DictionaryObject.__init__(self) field_attributes = ( FieldDictionaryAttributes.attributes() + CheckboxRadioButtonAttributes.attributes() ) self.indirect_reference = data.indirect_reference for attr in field_attributes: try: self[NameObject(attr)] = data[attr] except KeyError: pass
24,658
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Field.field_type
(self)
return self.get(FieldDictionaryAttributes.FT)
Read-only property accessing the type of this field.
Read-only property accessing the type of this field.
1,174
1,176
def field_type(self) -> Optional[NameObject]: """Read-only property accessing the type of this field.""" return self.get(FieldDictionaryAttributes.FT)
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1174-L1176
39
[ 0, 1, 2 ]
100
[]
0
true
92.337917
3
1
100
1
def field_type(self) -> Optional[NameObject]: return self.get(FieldDictionaryAttributes.FT)
24,659
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Field.fieldType
(self)
return self.field_type
.. deprecated:: 1.28.3 Use :py:attr:`field_type` instead.
.. deprecated:: 1.28.3
1,179
1,186
def fieldType(self) -> Optional[NameObject]: # deprecated """ .. deprecated:: 1.28.3 Use :py:attr:`field_type` instead. """ deprecation_with_replacement("fieldType", "field_type", "3.0.0") return self.field_type
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1179-L1186
39
[]
0
[]
0
false
92.337917
8
1
100
3
def fieldType(self) -> Optional[NameObject]: # deprecated deprecation_with_replacement("fieldType", "field_type", "3.0.0") return self.field_type
24,660
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Field.parent
(self)
return self.get(FieldDictionaryAttributes.Parent)
Read-only property accessing the parent of this field.
Read-only property accessing the parent of this field.
1,189
1,191
def parent(self) -> Optional[DictionaryObject]: """Read-only property accessing the parent of this field.""" return self.get(FieldDictionaryAttributes.Parent)
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1189-L1191
39
[ 0, 1, 2 ]
100
[]
0
true
92.337917
3
1
100
1
def parent(self) -> Optional[DictionaryObject]: return self.get(FieldDictionaryAttributes.Parent)
24,661
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Field.kids
(self)
return self.get(FieldDictionaryAttributes.Kids)
Read-only property accessing the kids of this field.
Read-only property accessing the kids of this field.
1,194
1,196
def kids(self) -> Optional["ArrayObject"]: """Read-only property accessing the kids of this field.""" return self.get(FieldDictionaryAttributes.Kids)
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1194-L1196
39
[ 0, 1, 2 ]
100
[]
0
true
92.337917
3
1
100
1
def kids(self) -> Optional["ArrayObject"]: return self.get(FieldDictionaryAttributes.Kids)
24,662
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Field.name
(self)
return self.get(FieldDictionaryAttributes.T)
Read-only property accessing the name of this field.
Read-only property accessing the name of this field.
1,199
1,201
def name(self) -> Optional[str]: """Read-only property accessing the name of this field.""" return self.get(FieldDictionaryAttributes.T)
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1199-L1201
39
[ 0, 1, 2 ]
100
[]
0
true
92.337917
3
1
100
1
def name(self) -> Optional[str]: return self.get(FieldDictionaryAttributes.T)
24,663
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Field.alternate_name
(self)
return self.get(FieldDictionaryAttributes.TU)
Read-only property accessing the alternate name of this field.
Read-only property accessing the alternate name of this field.
1,204
1,206
def alternate_name(self) -> Optional[str]: """Read-only property accessing the alternate name of this field.""" return self.get(FieldDictionaryAttributes.TU)
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1204-L1206
39
[ 0, 1, 2 ]
100
[]
0
true
92.337917
3
1
100
1
def alternate_name(self) -> Optional[str]: return self.get(FieldDictionaryAttributes.TU)
24,664
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Field.altName
(self)
return self.alternate_name
.. deprecated:: 1.28.3 Use :py:attr:`alternate_name` instead.
.. deprecated:: 1.28.3
1,209
1,216
def altName(self) -> Optional[str]: # deprecated """ .. deprecated:: 1.28.3 Use :py:attr:`alternate_name` instead. """ deprecation_with_replacement("altName", "alternate_name", "3.0.0") return self.alternate_name
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1209-L1216
39
[]
0
[]
0
false
92.337917
8
1
100
3
def altName(self) -> Optional[str]: # deprecated deprecation_with_replacement("altName", "alternate_name", "3.0.0") return self.alternate_name
24,665
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Field.mapping_name
(self)
return self.get(FieldDictionaryAttributes.TM)
Read-only property accessing the mapping name of this field. This name is used by pypdf as a key in the dictionary returned by :meth:`get_fields()<pypdf.PdfReader.get_fields>`
Read-only property accessing the mapping name of this field. This name is used by pypdf as a key in the dictionary returned by :meth:`get_fields()<pypdf.PdfReader.get_fields>`
1,219
1,225
def mapping_name(self) -> Optional[str]: """ Read-only property accessing the mapping name of this field. This name is used by pypdf as a key in the dictionary returned by :meth:`get_fields()<pypdf.PdfReader.get_fields>` """ return self.get(FieldDictionaryAttributes.TM)
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1219-L1225
39
[ 0, 1, 2, 3, 4, 5, 6 ]
100
[]
0
true
92.337917
7
1
100
3
def mapping_name(self) -> Optional[str]: return self.get(FieldDictionaryAttributes.TM)
24,666
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Field.mappingName
(self)
return self.mapping_name
.. deprecated:: 1.28.3 Use :py:attr:`mapping_name` instead.
.. deprecated:: 1.28.3
1,228
1,235
def mappingName(self) -> Optional[str]: # deprecated """ .. deprecated:: 1.28.3 Use :py:attr:`mapping_name` instead. """ deprecation_with_replacement("mappingName", "mapping_name", "3.0.0") return self.mapping_name
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1228-L1235
39
[]
0
[]
0
false
92.337917
8
1
100
3
def mappingName(self) -> Optional[str]: # deprecated deprecation_with_replacement("mappingName", "mapping_name", "3.0.0") return self.mapping_name
24,667
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Field.flags
(self)
return self.get(FieldDictionaryAttributes.Ff)
Read-only property accessing the field flags, specifying various characteristics of the field (see Table 8.70 of the PDF 1.7 reference).
Read-only property accessing the field flags, specifying various characteristics of the field (see Table 8.70 of the PDF 1.7 reference).
1,238
1,243
def flags(self) -> Optional[int]: """ Read-only property accessing the field flags, specifying various characteristics of the field (see Table 8.70 of the PDF 1.7 reference). """ return self.get(FieldDictionaryAttributes.Ff)
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1238-L1243
39
[ 0, 1, 2, 3, 4, 5 ]
100
[]
0
true
92.337917
6
1
100
2
def flags(self) -> Optional[int]: return self.get(FieldDictionaryAttributes.Ff)
24,668
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Field.value
(self)
return self.get(FieldDictionaryAttributes.V)
Read-only property accessing the value of this field. Format varies based on field type.
Read-only property accessing the value of this field. Format varies based on field type.
1,246
1,251
def value(self) -> Optional[Any]: """ Read-only property accessing the value of this field. Format varies based on field type. """ return self.get(FieldDictionaryAttributes.V)
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1246-L1251
39
[ 0, 1, 2, 3, 4, 5 ]
100
[]
0
true
92.337917
6
1
100
2
def value(self) -> Optional[Any]: return self.get(FieldDictionaryAttributes.V)
24,669
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Field.default_value
(self)
return self.get(FieldDictionaryAttributes.DV)
Read-only property accessing the default value of this field.
Read-only property accessing the default value of this field.
1,254
1,256
def default_value(self) -> Optional[Any]: """Read-only property accessing the default value of this field.""" return self.get(FieldDictionaryAttributes.DV)
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1254-L1256
39
[ 0, 1, 2 ]
100
[]
0
true
92.337917
3
1
100
1
def default_value(self) -> Optional[Any]: return self.get(FieldDictionaryAttributes.DV)
24,670
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Field.defaultValue
(self)
return self.default_value
.. deprecated:: 1.28.3 Use :py:attr:`default_value` instead.
.. deprecated:: 1.28.3
1,259
1,266
def defaultValue(self) -> Optional[Any]: # deprecated """ .. deprecated:: 1.28.3 Use :py:attr:`default_value` instead. """ deprecation_with_replacement("defaultValue", "default_value", "3.0.0") return self.default_value
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1259-L1266
39
[]
0
[]
0
false
92.337917
8
1
100
3
def defaultValue(self) -> Optional[Any]: # deprecated deprecation_with_replacement("defaultValue", "default_value", "3.0.0") return self.default_value
24,671
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Field.additional_actions
(self)
return self.get(FieldDictionaryAttributes.AA)
Read-only property accessing the additional actions dictionary. This dictionary defines the field's behavior in response to trigger events. See Section 8.5.2 of the PDF 1.7 reference.
Read-only property accessing the additional actions dictionary. This dictionary defines the field's behavior in response to trigger events. See Section 8.5.2 of the PDF 1.7 reference.
1,269
1,275
def additional_actions(self) -> Optional[DictionaryObject]: """ Read-only property accessing the additional actions dictionary. This dictionary defines the field's behavior in response to trigger events. See Section 8.5.2 of the PDF 1.7 reference. """ return self.get(FieldDictionaryAttributes.AA)
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1269-L1275
39
[ 0, 1, 2, 3, 4, 5, 6 ]
100
[]
0
true
92.337917
7
1
100
3
def additional_actions(self) -> Optional[DictionaryObject]: return self.get(FieldDictionaryAttributes.AA)
24,672
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Field.additionalActions
(self)
return self.additional_actions
.. deprecated:: 1.28.3 Use :py:attr:`additional_actions` instead.
.. deprecated:: 1.28.3
1,278
1,285
def additionalActions(self) -> Optional[DictionaryObject]: # deprecated """ .. deprecated:: 1.28.3 Use :py:attr:`additional_actions` instead. """ deprecation_with_replacement("additionalActions", "additional_actions", "3.0.0") return self.additional_actions
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1278-L1285
39
[]
0
[]
0
false
92.337917
8
1
100
3
def additionalActions(self) -> Optional[DictionaryObject]: # deprecated deprecation_with_replacement("additionalActions", "additional_actions", "3.0.0") return self.additional_actions
24,673
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Destination.__init__
( self, title: str, page: Union[NumberObject, IndirectObject, NullObject, DictionaryObject], fit: Fit, )
1,309
1,350
def __init__( self, title: str, page: Union[NumberObject, IndirectObject, NullObject, DictionaryObject], fit: Fit, ) -> None: typ = fit.fit_type args = fit.fit_args DictionaryObject.__init__(self) self[NameObject("/Title")] = TextStringObject(title) self[NameObject("/Page")] = page self[NameObject("/Type")] = typ # from table 8.2 of the PDF 1.7 reference. if typ == "/XYZ": ( self[NameObject(TA.LEFT)], self[NameObject(TA.TOP)], self[NameObject("/Zoom")], ) = args elif typ == TF.FIT_R: ( self[NameObject(TA.LEFT)], self[NameObject(TA.BOTTOM)], self[NameObject(TA.RIGHT)], self[NameObject(TA.TOP)], ) = args elif typ in [TF.FIT_H, TF.FIT_BH]: try: # Prefered to be more robust not only to null parameters (self[NameObject(TA.TOP)],) = args except Exception: (self[NameObject(TA.TOP)],) = (NullObject(),) elif typ in [TF.FIT_V, TF.FIT_BV]: try: # Prefered to be more robust not only to null parameters (self[NameObject(TA.LEFT)],) = args except Exception: (self[NameObject(TA.LEFT)],) = (NullObject(),) elif typ in [TF.FIT, TF.FIT_B]: pass else: raise PdfReadError(f"Unknown Destination Type: {typ!r}")
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1309-L1350
39
[ 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 21, 22, 28, 29, 30, 31, 32, 33, 34, 35, 38, 39, 41 ]
59.52381
[ 36, 37 ]
4.761905
false
92.337917
42
8
95.238095
0
def __init__( self, title: str, page: Union[NumberObject, IndirectObject, NullObject, DictionaryObject], fit: Fit, ) -> None: typ = fit.fit_type args = fit.fit_args DictionaryObject.__init__(self) self[NameObject("/Title")] = TextStringObject(title) self[NameObject("/Page")] = page self[NameObject("/Type")] = typ # from table 8.2 of the PDF 1.7 reference. if typ == "/XYZ": ( self[NameObject(TA.LEFT)], self[NameObject(TA.TOP)], self[NameObject("/Zoom")], ) = args elif typ == TF.FIT_R: ( self[NameObject(TA.LEFT)], self[NameObject(TA.BOTTOM)], self[NameObject(TA.RIGHT)], self[NameObject(TA.TOP)], ) = args elif typ in [TF.FIT_H, TF.FIT_BH]: try: # Prefered to be more robust not only to null parameters (self[NameObject(TA.TOP)],) = args except Exception: (self[NameObject(TA.TOP)],) = (NullObject(),) elif typ in [TF.FIT_V, TF.FIT_BV]: try: # Prefered to be more robust not only to null parameters (self[NameObject(TA.LEFT)],) = args except Exception: (self[NameObject(TA.LEFT)],) = (NullObject(),) elif typ in [TF.FIT, TF.FIT_B]: pass else: raise PdfReadError(f"Unknown Destination Type: {typ!r}")
24,674
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Destination.dest_array
(self)
return ArrayObject( [self.raw_get("/Page"), self["/Type"]] + [ self[x] for x in ["/Left", "/Bottom", "/Right", "/Top", "/Zoom"] if x in self ] )
1,353
1,361
def dest_array(self) -> "ArrayObject": return ArrayObject( [self.raw_get("/Page"), self["/Type"]] + [ self[x] for x in ["/Left", "/Bottom", "/Right", "/Top", "/Zoom"] if x in self ] )
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1353-L1361
39
[ 0, 1 ]
22.222222
[]
0
false
92.337917
9
2
100
0
def dest_array(self) -> "ArrayObject": return ArrayObject( [self.raw_get("/Page"), self["/Type"]] + [ self[x] for x in ["/Left", "/Bottom", "/Right", "/Top", "/Zoom"] if x in self ] )
24,675
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Destination.getDestArray
(self)
return self.dest_array
.. deprecated:: 1.28.3 Use :py:attr:`dest_array` instead.
.. deprecated:: 1.28.3
1,363
1,370
def getDestArray(self) -> "ArrayObject": # deprecated """ .. deprecated:: 1.28.3 Use :py:attr:`dest_array` instead. """ deprecation_with_replacement("getDestArray", "dest_array", "3.0.0") return self.dest_array
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1363-L1370
39
[]
0
[]
0
false
92.337917
8
1
100
3
def getDestArray(self) -> "ArrayObject": # deprecated deprecation_with_replacement("getDestArray", "dest_array", "3.0.0") return self.dest_array
24,676
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Destination.write_to_stream
( self, stream: StreamType, encryption_key: Union[None, str, bytes] )
1,372
1,389
def write_to_stream( self, stream: StreamType, encryption_key: Union[None, str, bytes] ) -> None: stream.write(b"<<\n") key = NameObject("/D") key.write_to_stream(stream, encryption_key) stream.write(b" ") value = self.dest_array value.write_to_stream(stream, encryption_key) key = NameObject("/S") key.write_to_stream(stream, encryption_key) stream.write(b" ") value_s = NameObject("/GoTo") value_s.write_to_stream(stream, encryption_key) stream.write(b"\n") stream.write(b">>")
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1372-L1389
39
[ 0 ]
5.555556
[ 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 16, 17 ]
72.222222
false
92.337917
18
1
27.777778
0
def write_to_stream( self, stream: StreamType, encryption_key: Union[None, str, bytes] ) -> None: stream.write(b"<<\n") key = NameObject("/D") key.write_to_stream(stream, encryption_key) stream.write(b" ") value = self.dest_array value.write_to_stream(stream, encryption_key) key = NameObject("/S") key.write_to_stream(stream, encryption_key) stream.write(b" ") value_s = NameObject("/GoTo") value_s.write_to_stream(stream, encryption_key) stream.write(b"\n") stream.write(b">>")
24,677
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Destination.title
(self)
return self.get("/Title")
Read-only property accessing the destination title.
Read-only property accessing the destination title.
1,392
1,394
def title(self) -> Optional[str]: """Read-only property accessing the destination title.""" return self.get("/Title")
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1392-L1394
39
[ 0, 1, 2 ]
100
[]
0
true
92.337917
3
1
100
1
def title(self) -> Optional[str]: return self.get("/Title")
24,678
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Destination.page
(self)
return self.get("/Page")
Read-only property accessing the destination page number.
Read-only property accessing the destination page number.
1,397
1,399
def page(self) -> Optional[int]: """Read-only property accessing the destination page number.""" return self.get("/Page")
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1397-L1399
39
[ 0, 1, 2 ]
100
[]
0
true
92.337917
3
1
100
1
def page(self) -> Optional[int]: return self.get("/Page")
24,679
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Destination.typ
(self)
return self.get("/Type")
Read-only property accessing the destination type.
Read-only property accessing the destination type.
1,402
1,404
def typ(self) -> Optional[str]: """Read-only property accessing the destination type.""" return self.get("/Type")
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1402-L1404
39
[ 0, 1, 2 ]
100
[]
0
true
92.337917
3
1
100
1
def typ(self) -> Optional[str]: return self.get("/Type")
24,680
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Destination.zoom
(self)
return self.get("/Zoom", None)
Read-only property accessing the zoom factor.
Read-only property accessing the zoom factor.
1,407
1,409
def zoom(self) -> Optional[int]: """Read-only property accessing the zoom factor.""" return self.get("/Zoom", None)
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1407-L1409
39
[ 0, 1, 2 ]
100
[]
0
true
92.337917
3
1
100
1
def zoom(self) -> Optional[int]: return self.get("/Zoom", None)
24,681
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Destination.left
(self)
return self.get("/Left", None)
Read-only property accessing the left horizontal coordinate.
Read-only property accessing the left horizontal coordinate.
1,412
1,414
def left(self) -> Optional[FloatObject]: """Read-only property accessing the left horizontal coordinate.""" return self.get("/Left", None)
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1412-L1414
39
[ 0, 1, 2 ]
100
[]
0
true
92.337917
3
1
100
1
def left(self) -> Optional[FloatObject]: return self.get("/Left", None)
24,682
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Destination.right
(self)
return self.get("/Right", None)
Read-only property accessing the right horizontal coordinate.
Read-only property accessing the right horizontal coordinate.
1,417
1,419
def right(self) -> Optional[FloatObject]: """Read-only property accessing the right horizontal coordinate.""" return self.get("/Right", None)
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1417-L1419
39
[ 0, 1, 2 ]
100
[]
0
true
92.337917
3
1
100
1
def right(self) -> Optional[FloatObject]: return self.get("/Right", None)
24,683
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Destination.top
(self)
return self.get("/Top", None)
Read-only property accessing the top vertical coordinate.
Read-only property accessing the top vertical coordinate.
1,422
1,424
def top(self) -> Optional[FloatObject]: """Read-only property accessing the top vertical coordinate.""" return self.get("/Top", None)
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1422-L1424
39
[ 0, 1, 2 ]
100
[]
0
true
92.337917
3
1
100
1
def top(self) -> Optional[FloatObject]: return self.get("/Top", None)
24,684
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Destination.bottom
(self)
return self.get("/Bottom", None)
Read-only property accessing the bottom vertical coordinate.
Read-only property accessing the bottom vertical coordinate.
1,427
1,429
def bottom(self) -> Optional[FloatObject]: """Read-only property accessing the bottom vertical coordinate.""" return self.get("/Bottom", None)
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1427-L1429
39
[ 0, 1, 2 ]
100
[]
0
true
92.337917
3
1
100
1
def bottom(self) -> Optional[FloatObject]: return self.get("/Bottom", None)
24,685
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Destination.color
(self)
return self.get( "/C", ArrayObject([FloatObject(0), FloatObject(0), FloatObject(0)]) )
Read-only property accessing the color in (R, G, B) with values 0.0-1.0
Read-only property accessing the color in (R, G, B) with values 0.0-1.0
1,432
1,436
def color(self) -> Optional["ArrayObject"]: """Read-only property accessing the color in (R, G, B) with values 0.0-1.0""" return self.get( "/C", ArrayObject([FloatObject(0), FloatObject(0), FloatObject(0)]) )
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1432-L1436
39
[ 0, 1, 2, 3, 4 ]
100
[]
0
true
92.337917
5
1
100
1
def color(self) -> Optional["ArrayObject"]: return self.get( "/C", ArrayObject([FloatObject(0), FloatObject(0), FloatObject(0)]) )
24,686
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Destination.font_format
(self)
return self.get("/F", 0)
Read-only property accessing the font type. 1=italic, 2=bold, 3=both
Read-only property accessing the font type. 1=italic, 2=bold, 3=both
1,439
1,441
def font_format(self) -> Optional[OutlineFontFlag]: """Read-only property accessing the font type. 1=italic, 2=bold, 3=both""" return self.get("/F", 0)
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1439-L1441
39
[ 0, 1, 2 ]
100
[]
0
true
92.337917
3
1
100
1
def font_format(self) -> Optional[OutlineFontFlag]: return self.get("/F", 0)
24,687
py-pdf/pypdf
d942a49074de9fb89ea374cd7f36f6d74a4a3451
pypdf/generic/_data_structures.py
Destination.outline_count
(self)
return self.get("/Count", None)
Read-only property accessing the outline count. positive = expanded negative = collapsed absolute value = number of visible descendents at all levels
Read-only property accessing the outline count. positive = expanded negative = collapsed absolute value = number of visible descendents at all levels
1,444
1,451
def outline_count(self) -> Optional[int]: """ Read-only property accessing the outline count. positive = expanded negative = collapsed absolute value = number of visible descendents at all levels """ return self.get("/Count", None)
https://github.com/py-pdf/pypdf/blob/d942a49074de9fb89ea374cd7f36f6d74a4a3451/project39/pypdf/generic/_data_structures.py#L1444-L1451
39
[ 0, 1, 2, 3, 4, 5, 6 ]
87.5
[ 7 ]
12.5
false
92.337917
8
1
87.5
4
def outline_count(self) -> Optional[int]: return self.get("/Count", None)
24,688
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourcesearch.py
_iter_parents
(path)
6
11
def _iter_parents(path): path = path.strip("/") if path: pieces = path.split("/") for x in range(len(pieces)): yield "/" + "/".join(pieces[:x])
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourcesearch.py#L6-L11
40
[ 0, 1, 2, 3, 4, 5 ]
100
[]
0
true
89.873418
6
3
100
0
def _iter_parents(path): path = path.strip("/") if path: pieces = path.split("/") for x in range(len(pieces)): yield "/" + "/".join(pieces[:x])
25,744
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourcesearch.py
_find_info
(infos, alt, lang)
return None
14
18
def _find_info(infos, alt, lang): for info in infos: if info["alt"] == alt and info["lang"] == lang: return info return None
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourcesearch.py#L14-L18
40
[ 0, 1, 2, 3, 4 ]
100
[]
0
true
89.873418
5
4
100
0
def _find_info(infos, alt, lang): for info in infos: if info["alt"] == alt and info["lang"] == lang: return info return None
25,745
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourcesearch.py
_id_from_path
(path)
21
25
def _id_from_path(path): try: return path.strip("/").split("/")[-1] except IndexError: return ""
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourcesearch.py#L21-L25
40
[ 0, 1, 2 ]
60
[ 3, 4 ]
40
false
89.873418
5
2
60
0
def _id_from_path(path): try: return path.strip("/").split("/")[-1] except IndexError: return ""
25,746
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourcesearch.py
_mapping_from_cursor
(cur)
return rv
28
41
def _mapping_from_cursor(cur): rv = {} for path, alt, lang, type, title in cur.fetchall(): rv.setdefault(path, []).append( { "id": _id_from_path(path), "path": path, "alt": alt, "type": type, "lang": lang, "title": title, } ) return rv
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourcesearch.py#L28-L41
40
[ 0, 1, 2, 3, 13 ]
35.714286
[]
0
false
89.873418
14
2
100
0
def _mapping_from_cursor(cur): rv = {} for path, alt, lang, type, title in cur.fetchall(): rv.setdefault(path, []).append( { "id": _id_from_path(path), "path": path, "alt": alt, "type": type, "lang": lang, "title": title, } ) return rv
25,747
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourcesearch.py
_find_best_info
(infos, alt, lang)
return None
44
54
def _find_best_info(infos, alt, lang): for _alt, _lang in [ (alt, lang), (PRIMARY_ALT, lang), (alt, "en"), (PRIMARY_ALT, "en"), ]: rv = _find_info(infos, _alt, _lang) if rv is not None: return rv return None
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourcesearch.py#L44-L54
40
[ 0, 1, 7, 8, 9 ]
45.454545
[ 10 ]
9.090909
false
89.873418
11
3
90.909091
0
def _find_best_info(infos, alt, lang): for _alt, _lang in [ (alt, lang), (PRIMARY_ALT, lang), (alt, "en"), (PRIMARY_ALT, "en"), ]: rv = _find_info(infos, _alt, _lang) if rv is not None: return rv return None
25,748
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourcesearch.py
_build_parent_path
(path, mapping, alt, lang)
return rv
57
67
def _build_parent_path(path, mapping, alt, lang): rv = [] for parent in _iter_parents(path): info = _find_best_info(mapping.get(parent) or [], alt, lang) id = _id_from_path(parent) if info is None: title = id or "(Index)" else: title = info.get("title") rv.append({"id": id, "path": parent, "title": title}) return rv
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourcesearch.py#L57-L67
40
[ 0, 1, 2, 3, 4, 5, 8, 9, 10 ]
81.818182
[ 6 ]
9.090909
false
89.873418
11
5
90.909091
0
def _build_parent_path(path, mapping, alt, lang): rv = [] for parent in _iter_parents(path): info = _find_best_info(mapping.get(parent) or [], alt, lang) id = _id_from_path(parent) if info is None: title = id or "(Index)" else: title = info.get("title") rv.append({"id": id, "path": parent, "title": title}) return rv
25,749
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourcesearch.py
_process_search_results
(builder, cur, alt, lang, limit)
return rv
70
104
def _process_search_results(builder, cur, alt, lang, limit): mapping = _mapping_from_cursor(cur) rv = [] files_needed = set() for path, infos in mapping.items(): info = _find_best_info(infos, alt, lang) if info is None: continue for parent in _iter_parents(path): if parent not in mapping: files_needed.add(parent) rv.append(info) if len(rv) == limit: break if files_needed: cur.execute( """ select path, alt, lang, type, title from source_info where path in (%s) """ % ", ".join(["?"] * len(files_needed)), list(files_needed), ) mapping.update(_mapping_from_cursor(cur)) for info in rv: info["parents"] = _build_parent_path(info["path"], mapping, alt, lang) return rv
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourcesearch.py#L70-L104
40
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34 ]
94.285714
[ 9, 17 ]
5.714286
false
89.873418
35
8
94.285714
0
def _process_search_results(builder, cur, alt, lang, limit): mapping = _mapping_from_cursor(cur) rv = [] files_needed = set() for path, infos in mapping.items(): info = _find_best_info(infos, alt, lang) if info is None: continue for parent in _iter_parents(path): if parent not in mapping: files_needed.add(parent) rv.append(info) if len(rv) == limit: break if files_needed: cur.execute( % ", ".join(["?"] * len(files_needed)), list(files_needed), ) mapping.update(_mapping_from_cursor(cur)) for info in rv: info["parents"] = _build_parent_path(info["path"], mapping, alt, lang) return rv
25,750
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourcesearch.py
find_files
(builder, query, alt=PRIMARY_ALT, lang=None, limit=50, types=None)
107
149
def find_files(builder, query, alt=PRIMARY_ALT, lang=None, limit=50, types=None): if types is None: types = ["page"] else: types = list(types) languages = ["en"] if lang not in ("en", None): languages.append(lang) else: lang = "en" alts = [PRIMARY_ALT] if alt != PRIMARY_ALT: alts.append(alt) query = query.strip() title_like = "%" + query + "%" path_like = "/%" + query.rstrip("/") + "%" con = sqlite3.connect(builder.buildstate_database_filename, timeout=10) try: cur = con.cursor() cur.execute( """ select path, alt, lang, type, title from source_info where (title like ? or path like ?) and lang in (%s) and alt in (%s) and type in (%s) order by title collate nocase limit ? """ % ( ", ".join(["?"] * len(languages)), ", ".join(["?"] * len(alts)), ", ".join(["?"] * len(types)), ), [title_like, path_like] + languages + alts + types + [limit * 2], ) return _process_search_results(builder, cur, alt, lang, limit) finally: con.close()
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourcesearch.py#L107-L149
40
[ 0, 1, 2, 5, 6, 7, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 ]
90.697674
[ 4, 12 ]
4.651163
false
89.873418
43
4
95.348837
0
def find_files(builder, query, alt=PRIMARY_ALT, lang=None, limit=50, types=None): if types is None: types = ["page"] else: types = list(types) languages = ["en"] if lang not in ("en", None): languages.append(lang) else: lang = "en" alts = [PRIMARY_ALT] if alt != PRIMARY_ALT: alts.append(alt) query = query.strip() title_like = "%" + query + "%" path_like = "/%" + query.rstrip("/") + "%" con = sqlite3.connect(builder.buildstate_database_filename, timeout=10) try: cur = con.cursor() cur.execute( % ( ", ".join(["?"] * len(languages)), ", ".join(["?"] * len(alts)), ", ".join(["?"] * len(types)), ), [title_like, path_like] + languages + alts + types + [limit * 2], ) return _process_search_results(builder, cur, alt, lang, limit) finally: con.close()
25,751
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourceobj.py
SourceObject.__init__
(self, pad)
20
21
def __init__(self, pad): self._pad = weakref(pad)
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourceobj.py#L20-L21
40
[ 0, 1 ]
100
[]
0
true
88.8
2
1
100
0
def __init__(self, pad): self._pad = weakref(pad)
25,752
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourceobj.py
SourceObject.alt
(self)
return PRIMARY_ALT
Returns the effective alt of this source object (unresolved).
Returns the effective alt of this source object (unresolved).
24
26
def alt(self): """Returns the effective alt of this source object (unresolved).""" return PRIMARY_ALT
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourceobj.py#L24-L26
40
[ 0, 1 ]
66.666667
[ 2 ]
33.333333
false
88.8
3
1
66.666667
1
def alt(self): return PRIMARY_ALT
25,753
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourceobj.py
SourceObject.source_filename
(self)
The primary source filename of this source object.
The primary source filename of this source object.
29
30
def source_filename(self): """The primary source filename of this source object."""
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourceobj.py#L29-L30
40
[ 0, 1 ]
100
[]
0
true
88.8
2
1
100
1
def source_filename(self):
25,754
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourceobj.py
SourceObject.is_visible
(self)
return not self.is_hidden
The negated version of :attr:`is_hidden`.
The negated version of :attr:`is_hidden`.
36
38
def is_visible(self): """The negated version of :attr:`is_hidden`.""" return not self.is_hidden
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourceobj.py#L36-L38
40
[ 0, 1, 2 ]
100
[]
0
true
88.8
3
1
100
1
def is_visible(self): return not self.is_hidden
25,755
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourceobj.py
SourceObject.is_undiscoverable
(self)
return not self.is_discoverable
The negated version of :attr:`is_discoverable`.
The negated version of :attr:`is_discoverable`.
41
43
def is_undiscoverable(self): """The negated version of :attr:`is_discoverable`.""" return not self.is_discoverable
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourceobj.py#L41-L43
40
[ 0, 1, 2 ]
100
[]
0
true
88.8
3
1
100
1
def is_undiscoverable(self): return not self.is_discoverable
25,756
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourceobj.py
SourceObject.iter_source_filenames
(self)
45
48
def iter_source_filenames(self): fn = self.source_filename if fn is not None: yield self.source_filename
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourceobj.py#L45-L48
40
[ 0 ]
25
[ 1, 2, 3 ]
75
false
88.8
4
2
25
0
def iter_source_filenames(self): fn = self.source_filename if fn is not None: yield self.source_filename
25,757
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourceobj.py
SourceObject.iter_virtual_sources
(self)
return []
50
52
def iter_virtual_sources(self): # pylint: disable=no-self-use return []
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourceobj.py#L50-L52
40
[ 0, 1, 2 ]
100
[]
0
true
88.8
3
1
100
0
def iter_virtual_sources(self): # pylint: disable=no-self-use return []
25,758
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourceobj.py
SourceObject.url_path
(self)
The URL path of this source object if available.
The URL path of this source object if available.
55
57
def url_path(self): """The URL path of this source object if available.""" raise NotImplementedError()
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourceobj.py#L55-L57
40
[ 0, 1, 2 ]
100
[]
0
true
88.8
3
1
100
1
def url_path(self): raise NotImplementedError()
25,759
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourceobj.py
SourceObject.path
(self)
return None
Return the full path to the source object. Not every source object actually has a path but source objects without paths need to subclass `VirtualSourceObject`.
Return the full path to the source object. Not every source object actually has a path but source objects without paths need to subclass `VirtualSourceObject`.
60
65
def path(self): """Return the full path to the source object. Not every source object actually has a path but source objects without paths need to subclass `VirtualSourceObject`. """ return None
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourceobj.py#L60-L65
40
[ 0, 1, 2, 3, 4 ]
83.333333
[ 5 ]
16.666667
false
88.8
6
1
83.333333
3
def path(self): return None
25,760
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourceobj.py
SourceObject.pad
(self)
The associated pad of this source object.
The associated pad of this source object.
68
73
def pad(self): """The associated pad of this source object.""" rv = self._pad() if rv is not None: return rv raise AttributeError("The pad went away")
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourceobj.py#L68-L73
40
[ 0, 1, 2, 3, 4 ]
83.333333
[ 5 ]
16.666667
false
88.8
6
2
83.333333
1
def pad(self): rv = self._pad() if rv is not None: return rv raise AttributeError("The pad went away")
25,761
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourceobj.py
SourceObject.resolve_url_path
(self, url_path)
return None
Given a URL path as list this resolves the most appropriate direct child and returns the list of remaining items. If no match can be found, the result is `None`.
Given a URL path as list this resolves the most appropriate direct child and returns the list of remaining items. If no match can be found, the result is `None`.
75
82
def resolve_url_path(self, url_path): """Given a URL path as list this resolves the most appropriate direct child and returns the list of remaining items. If no match can be found, the result is `None`. """ if not url_path: return self return None
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourceobj.py#L75-L82
40
[ 0, 1, 2, 3, 4, 5, 6 ]
87.5
[ 7 ]
12.5
false
88.8
8
2
87.5
3
def resolve_url_path(self, url_path): if not url_path: return self return None
25,762
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourceobj.py
SourceObject.is_child_of
(self, path, strict=False)
return is_path_child_of(self.path, path, strict=strict)
Checks if the current object is a child of the passed object or path.
Checks if the current object is a child of the passed object or path.
84
92
def is_child_of(self, path, strict=False): """Checks if the current object is a child of the passed object or path. """ if isinstance(path, SourceObject): path = path.path if self.path is None or path is None: return False return is_path_child_of(self.path, path, strict=strict)
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourceobj.py#L84-L92
40
[ 0, 1, 2, 3, 4, 5, 6, 8 ]
88.888889
[ 7 ]
11.111111
false
88.8
9
4
88.888889
2
def is_child_of(self, path, strict=False): if isinstance(path, SourceObject): path = path.path if self.path is None or path is None: return False return is_path_child_of(self.path, path, strict=strict)
25,763
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourceobj.py
SourceObject.url_to
( self, path, # : Union[str, "SourceObject", "SupportsUrlPath"] alt: Optional[str] = None, absolute: Optional[bool] = None, external: Optional[bool] = None, base_url: Optional[str] = None, resolve: Optional[bool] = None, strict_resolve: Optional[bool] = None, )
return self.pad.make_url(url_path, base_url, absolute, external)
Calculates the URL from the current source object to the given other source object. Alternatively a path can also be provided instead of a source object. If the path starts with a leading bang (``!``) then no resolving is performed. If a `base_url` is provided then it's used instead of the URL of the record itself. If path is a string and resolve=False is passed, then no attempt is made to resolve the path to a Lektor source object. If path is a string and strict_resolve=True is passed, then an exception is raised if the path can not be resolved to a Lektor source object. API CHANGE: It used to be (lektor <= 3.3.1) that if absolute was true-ish, then a url_path (URL path relative to the site's ``base_path`` was returned. This is changed so that now an absolute URL path is returned.
Calculates the URL from the current source object to the given other source object. Alternatively a path can also be provided instead of a source object. If the path starts with a leading bang (``!``) then no resolving is performed.
94
165
def url_to( self, path, # : Union[str, "SourceObject", "SupportsUrlPath"] alt: Optional[str] = None, absolute: Optional[bool] = None, external: Optional[bool] = None, base_url: Optional[str] = None, resolve: Optional[bool] = None, strict_resolve: Optional[bool] = None, ) -> str: """Calculates the URL from the current source object to the given other source object. Alternatively a path can also be provided instead of a source object. If the path starts with a leading bang (``!``) then no resolving is performed. If a `base_url` is provided then it's used instead of the URL of the record itself. If path is a string and resolve=False is passed, then no attempt is made to resolve the path to a Lektor source object. If path is a string and strict_resolve=True is passed, then an exception is raised if the path can not be resolved to a Lektor source object. API CHANGE: It used to be (lektor <= 3.3.1) that if absolute was true-ish, then a url_path (URL path relative to the site's ``base_path`` was returned. This is changed so that now an absolute URL path is returned. """ if base_url is None: base_url = self.url_path if absolute: # This sort of reproduces the old behaviour, where when # ``absolute`` was trueish, the "absolute" URL path # (relative to config.base_path) was returned, regardless # of the value of ``external``. external = False if resolve is None and strict_resolve: resolve = True if isinstance(path, SourceObject): # assert not isinstance(path, Asset) target = path if alt is not None and alt != target.alt: # NB: path.path includes page_num alt_target = self.pad.get(path.path, alt=alt, persist=False) if alt_target is not None: target = alt_target # FIXME: issue warning or fail if cannot get correct alt? url_path = target.url_path elif hasattr(path, "url_path"): # e.g. Thumbnail assert path.url_path.startswith("/") url_path = path.url_path elif path[:1] == "!": # XXX: error if used with explicit alt? if resolve: raise RuntimeError("Resolve=True is incompatible with '!' prefix.") url_path = posixpath.join(self.url_path, path[1:]) elif resolve is not None and not resolve: # XXX: error if used with explicit alt? url_path = posixpath.join(self.url_path, path) else: with ignore_url_unaffecting_dependencies(): return self._resolve_url( path, alt=alt, absolute=absolute, external=external, base_url=base_url, strict=strict_resolve, ) return self.pad.make_url(url_path, base_url, absolute, external)
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourceobj.py#L94-L165
40
[ 0, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71 ]
63.888889
[]
0
false
88.8
72
16
100
17
def url_to( self, path, # : Union[str, "SourceObject", "SupportsUrlPath"] alt: Optional[str] = None, absolute: Optional[bool] = None, external: Optional[bool] = None, base_url: Optional[str] = None, resolve: Optional[bool] = None, strict_resolve: Optional[bool] = None, ) -> str: if base_url is None: base_url = self.url_path if absolute: # This sort of reproduces the old behaviour, where when # ``absolute`` was trueish, the "absolute" URL path # (relative to config.base_path) was returned, regardless # of the value of ``external``. external = False if resolve is None and strict_resolve: resolve = True if isinstance(path, SourceObject): # assert not isinstance(path, Asset) target = path if alt is not None and alt != target.alt: # NB: path.path includes page_num alt_target = self.pad.get(path.path, alt=alt, persist=False) if alt_target is not None: target = alt_target # FIXME: issue warning or fail if cannot get correct alt? url_path = target.url_path elif hasattr(path, "url_path"): # e.g. Thumbnail assert path.url_path.startswith("/") url_path = path.url_path elif path[:1] == "!": # XXX: error if used with explicit alt? if resolve: raise RuntimeError("Resolve=True is incompatible with '!' prefix.") url_path = posixpath.join(self.url_path, path[1:]) elif resolve is not None and not resolve: # XXX: error if used with explicit alt? url_path = posixpath.join(self.url_path, path) else: with ignore_url_unaffecting_dependencies(): return self._resolve_url( path, alt=alt, absolute=absolute, external=external, base_url=base_url, strict=strict_resolve, ) return self.pad.make_url(url_path, base_url, absolute, external)
25,764
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourceobj.py
SourceObject._resolve_url
( self, _url: str, alt: Optional[str], absolute: Optional[bool], external: Optional[bool], base_url: Optional[str], strict: Optional[bool], )
return resolved.geturl()
Resolve (possibly relative) URL or db path to URL.
Resolve (possibly relative) URL or db path to URL.
167
205
def _resolve_url( self, _url: str, alt: Optional[str], absolute: Optional[bool], external: Optional[bool], base_url: Optional[str], strict: Optional[bool], ) -> str: """Resolve (possibly relative) URL or db path to URL.""" url = urlsplit(_url) if url.scheme or url.netloc: resolved = url else: # Interpret path as (possibly relative) db-path dbpath = join_path(self.path, url.path) params = dict(parse_qsl(url.query, keep_blank_values=False)) query_alt = params.get("alt") # XXX: support page_num in query, too? if not alt: alt = query_alt or self.alt elif query_alt and query_alt != alt: raise RuntimeError("Conflicting values for alt.") target = self.pad.get(dbpath, alt=alt) if target is not None: url_path = target.url_path query = "" elif strict: raise RuntimeError(f"Can not resolve link {_url!r}") else: # Fall back to interpreting path as (possibly relative) URL path url_path = posixpath.join(self.url_path, url.path) query = url.query result = self.pad.make_url( url_path, absolute=absolute, external=external, base_url=base_url ) resolved = urlsplit(result)._replace(query=query, fragment=url.fragment) return resolved.geturl()
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourceobj.py#L167-L205
40
[ 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38 ]
79.487179
[]
0
false
88.8
39
9
100
1
def _resolve_url( self, _url: str, alt: Optional[str], absolute: Optional[bool], external: Optional[bool], base_url: Optional[str], strict: Optional[bool], ) -> str: url = urlsplit(_url) if url.scheme or url.netloc: resolved = url else: # Interpret path as (possibly relative) db-path dbpath = join_path(self.path, url.path) params = dict(parse_qsl(url.query, keep_blank_values=False)) query_alt = params.get("alt") # XXX: support page_num in query, too? if not alt: alt = query_alt or self.alt elif query_alt and query_alt != alt: raise RuntimeError("Conflicting values for alt.") target = self.pad.get(dbpath, alt=alt) if target is not None: url_path = target.url_path query = "" elif strict: raise RuntimeError(f"Can not resolve link {_url!r}") else: # Fall back to interpreting path as (possibly relative) URL path url_path = posixpath.join(self.url_path, url.path) query = url.query result = self.pad.make_url( url_path, absolute=absolute, external=external, base_url=base_url ) resolved = urlsplit(result)._replace(query=query, fragment=url.fragment) return resolved.geturl()
25,765
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourceobj.py
VirtualSourceObject.__init__
(self, record)
213
215
def __init__(self, record): SourceObject.__init__(self, record.pad) self.record = record
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourceobj.py#L213-L215
40
[ 0, 1, 2 ]
100
[]
0
true
88.8
3
1
100
0
def __init__(self, record): SourceObject.__init__(self, record.pad) self.record = record
25,766
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourceobj.py
VirtualSourceObject.get_mtime
(self, path_cache)
return None
221
223
def get_mtime(self, path_cache): # pylint: disable=no-self-use return None
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourceobj.py#L221-L223
40
[ 0, 1 ]
66.666667
[ 2 ]
33.333333
false
88.8
3
1
66.666667
0
def get_mtime(self, path_cache): # pylint: disable=no-self-use return None
25,767
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourceobj.py
VirtualSourceObject.get_checksum
(self, path_cache)
return None
225
227
def get_checksum(self, path_cache): # pylint: disable=no-self-use return None
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourceobj.py#L225-L227
40
[ 0, 1 ]
66.666667
[ 2 ]
33.333333
false
88.8
3
1
66.666667
0
def get_checksum(self, path_cache): # pylint: disable=no-self-use return None
25,768
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourceobj.py
VirtualSourceObject.parent
(self)
return self.record
230
231
def parent(self): return self.record
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourceobj.py#L230-L231
40
[ 0 ]
50
[ 1 ]
50
false
88.8
2
1
50
0
def parent(self): return self.record
25,769
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourceobj.py
VirtualSourceObject.alt
(self)
return self.record.alt
234
235
def alt(self): return self.record.alt
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourceobj.py#L234-L235
40
[ 0 ]
50
[ 1 ]
50
false
88.8
2
1
50
0
def alt(self): return self.record.alt
25,770
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourceobj.py
VirtualSourceObject.source_filename
(self)
return self.record.source_filename
238
239
def source_filename(self): return self.record.source_filename
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourceobj.py#L238-L239
40
[ 0 ]
50
[ 1 ]
50
false
88.8
2
1
50
0
def source_filename(self): return self.record.source_filename
25,771
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/sourceobj.py
VirtualSourceObject.iter_virtual_sources
(self)
241
242
def iter_virtual_sources(self): yield self
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/sourceobj.py#L241-L242
40
[ 0, 1 ]
100
[]
0
true
88.8
2
1
100
0
def iter_virtual_sources(self): yield self
25,772
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/buildfailures.py
BuildFailure.__init__
(self, data)
9
10
def __init__(self, data): self.data = data
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/buildfailures.py#L9-L10
40
[ 0, 1 ]
100
[]
0
true
100
2
1
100
0
def __init__(self, data): self.data = data
25,773
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/buildfailures.py
BuildFailure.from_exc_info
(cls, artifact_name, exc_info)
return cls( { "artifact": artifact_name, "exception": "".join(te.format_exception_only()).strip(), "traceback": "".join(te.format()).strip(), } )
13
23
def from_exc_info(cls, artifact_name, exc_info): te = TracebackException(*exc_info) # NB: we have dropped werkzeug's support for Paste's __traceback_hide__ # frame local. return cls( { "artifact": artifact_name, "exception": "".join(te.format_exception_only()).strip(), "traceback": "".join(te.format()).strip(), } )
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/buildfailures.py#L13-L23
40
[ 0, 1, 2, 3, 4 ]
45.454545
[]
0
false
100
11
1
100
0
def from_exc_info(cls, artifact_name, exc_info): te = TracebackException(*exc_info) # NB: we have dropped werkzeug's support for Paste's __traceback_hide__ # frame local. return cls( { "artifact": artifact_name, "exception": "".join(te.format_exception_only()).strip(), "traceback": "".join(te.format()).strip(), } )
25,774
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/buildfailures.py
BuildFailure.to_json
(self)
return self.data
25
26
def to_json(self): return self.data
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/buildfailures.py#L25-L26
40
[ 0, 1 ]
100
[]
0
true
100
2
1
100
0
def to_json(self): return self.data
25,775
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/buildfailures.py
FailureController.__init__
(self, pad, destination_path)
30
36
def __init__(self, pad, destination_path): self.pad = pad self.path = os.path.join( os.path.abspath(os.path.join(pad.db.env.root_path, destination_path)), ".lektor", "failures", )
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/buildfailures.py#L30-L36
40
[ 0, 1, 2 ]
42.857143
[]
0
false
100
7
1
100
0
def __init__(self, pad, destination_path): self.pad = pad self.path = os.path.join( os.path.abspath(os.path.join(pad.db.env.root_path, destination_path)), ".lektor", "failures", )
25,776
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/buildfailures.py
FailureController.get_filename
(self, artifact_name)
return ( os.path.join( self.path, hashlib.md5(artifact_name.encode("utf-8")).hexdigest() ) + ".json" )
38
44
def get_filename(self, artifact_name): return ( os.path.join( self.path, hashlib.md5(artifact_name.encode("utf-8")).hexdigest() ) + ".json" )
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/buildfailures.py#L38-L44
40
[ 0, 1 ]
28.571429
[]
0
false
100
7
1
100
0
def get_filename(self, artifact_name): return ( os.path.join( self.path, hashlib.md5(artifact_name.encode("utf-8")).hexdigest() ) + ".json" )
25,777
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/buildfailures.py
FailureController.lookup_failure
(self, artifact_name)
Looks up a failure for the given artifact name.
Looks up a failure for the given artifact name.
46
55
def lookup_failure(self, artifact_name): """Looks up a failure for the given artifact name.""" fn = self.get_filename(artifact_name) try: with open(fn, "r", encoding="utf-8") as f: return BuildFailure(json.load(f)) except IOError as e: if e.errno != errno.ENOENT: raise return None
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/buildfailures.py#L46-L55
40
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
100
[]
0
true
100
10
4
100
1
def lookup_failure(self, artifact_name): fn = self.get_filename(artifact_name) try: with open(fn, "r", encoding="utf-8") as f: return BuildFailure(json.load(f)) except IOError as e: if e.errno != errno.ENOENT: raise return None
25,778
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/buildfailures.py
FailureController.clear_failure
(self, artifact_name)
Clears a stored failure.
Clears a stored failure.
57
63
def clear_failure(self, artifact_name): """Clears a stored failure.""" try: os.unlink(self.get_filename(artifact_name)) except OSError as e: if e.errno != errno.ENOENT: raise
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/buildfailures.py#L57-L63
40
[ 0, 1, 2, 3, 4, 5, 6 ]
100
[]
0
true
100
7
3
100
1
def clear_failure(self, artifact_name): try: os.unlink(self.get_filename(artifact_name)) except OSError as e: if e.errno != errno.ENOENT: raise
25,779
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/buildfailures.py
FailureController.store_failure
(self, artifact_name, exc_info)
Stores a failure from an exception info tuple.
Stores a failure from an exception info tuple.
65
74
def store_failure(self, artifact_name, exc_info): """Stores a failure from an exception info tuple.""" fn = self.get_filename(artifact_name) try: os.makedirs(os.path.dirname(fn)) except OSError: pass with open(fn, mode="w", encoding="utf-8") as f: json.dump(BuildFailure.from_exc_info(artifact_name, exc_info).to_json(), f) f.write("\n")
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/buildfailures.py#L65-L74
40
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
100
[]
0
true
100
10
3
100
1
def store_failure(self, artifact_name, exc_info): fn = self.get_filename(artifact_name) try: os.makedirs(os.path.dirname(fn)) except OSError: pass with open(fn, mode="w", encoding="utf-8") as f: json.dump(BuildFailure.from_exc_info(artifact_name, exc_info).to_json(), f) f.write("\n")
25,780
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/quickstart.py
get_default_author
()
return getpass.getuser()
Attempt to guess an the name of the current user.
Attempt to guess an the name of the current user.
131
143
def get_default_author() -> str: """Attempt to guess an the name of the current user.""" if pwd is not None: try: pw_gecos = pwd.getpwuid(os.getuid()).pw_gecos except KeyError: pass else: full_name = pw_gecos.split(",", 1)[0].strip() if full_name: return full_name return getpass.getuser()
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/quickstart.py#L131-L143
40
[ 0, 1 ]
15.384615
[ 2, 3, 4, 5, 6, 8, 9, 10, 12 ]
69.230769
false
23.5
13
4
30.769231
1
def get_default_author() -> str: if pwd is not None: try: pw_gecos = pwd.getpwuid(os.getuid()).pw_gecos except KeyError: pass else: full_name = pw_gecos.split(",", 1)[0].strip() if full_name: return full_name return getpass.getuser()
25,786
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/quickstart.py
get_default_author_email
()
return None
Attempt to guess an email address for the current user. May return an empty string if not reasonable guess can be made.
Attempt to guess an email address for the current user.
146
165
def get_default_author_email() -> Optional[str]: """Attempt to guess an email address for the current user. May return an empty string if not reasonable guess can be made. """ git = locate_executable("git") if git: proc = run( (git, "config", "user.email"), stdout=PIPE, errors="strict", check=False ) if proc.returncode == 0: return proc.stdout.strip() email = os.environ.get("EMAIL", "").strip() if email: return email # We could fall back to f"{getpass.getuser()}@{socket.getfqdn()}", # but it is probably better just to go with no default in that # case. return None
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/quickstart.py#L146-L165
40
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 ]
100
[]
0
true
23.5
20
4
100
3
def get_default_author_email() -> Optional[str]: git = locate_executable("git") if git: proc = run( (git, "config", "user.email"), stdout=PIPE, errors="strict", check=False ) if proc.returncode == 0: return proc.stdout.strip() email = os.environ.get("EMAIL", "").strip() if email: return email # We could fall back to f"{getpass.getuser()}@{socket.getfqdn()}", # but it is probably better just to go with no default in that # case. return None
25,787
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/quickstart.py
project_quickstart
(defaults=None)
168
232
def project_quickstart(defaults=None): if not defaults: defaults = {} g = Generator("project") g.title("Lektor Quickstart") g.text( "This wizard will generate a new basic project with some sensible " "defaults for getting started quickly. We just need to go through " "a few questions so that the project is set up correctly for you." ) name = defaults.get("name") if name is None: name = g.prompt( "Project Name", None, "A project needs a name. The name is primarily used for the admin " "UI and some other places to refer to your project to not get " "confused if multiple projects exist. You can change this at " "any later point.", ) author_name = g.prompt( "Author Name", get_default_author(), "Your name. This is used in a few places in the default template " "to refer to in the default copyright messages.", ) path = defaults.get("path") if path is None: default_project_path = os.path.join(os.getcwd(), name) path = g.prompt( "Project Path", default_project_path, "This is the path where the project will be located. You can " "move a project around later if you do not like the path. If " "you provide a relative path it will be relative to the working " "directory.", ) path = os.path.expanduser(path) with_blog = g.prompt( "Add Basic Blog", True, "Do you want to generate a basic blog module? If you enable this " "the models for a very basic blog will be generated.", ) g.confirm("That's all. Create project?") g.run( { "project_name": name, "project_slug": slugify(name), "project_path": path, "with_blog": with_blog, "this_year": datetime.utcnow().year, "today": datetime.utcnow().strftime("%Y-%m-%d"), "author_name": author_name, }, path, )
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/quickstart.py#L168-L232
40
[ 0 ]
1.538462
[ 1, 2, 4, 6, 7, 13, 14, 15, 24, 31, 32, 33, 34, 42, 44, 51, 53 ]
26.153846
false
23.5
65
4
73.846154
0
def project_quickstart(defaults=None): if not defaults: defaults = {} g = Generator("project") g.title("Lektor Quickstart") g.text( "This wizard will generate a new basic project with some sensible " "defaults for getting started quickly. We just need to go through " "a few questions so that the project is set up correctly for you." ) name = defaults.get("name") if name is None: name = g.prompt( "Project Name", None, "A project needs a name. The name is primarily used for the admin " "UI and some other places to refer to your project to not get " "confused if multiple projects exist. You can change this at " "any later point.", ) author_name = g.prompt( "Author Name", get_default_author(), "Your name. This is used in a few places in the default template " "to refer to in the default copyright messages.", ) path = defaults.get("path") if path is None: default_project_path = os.path.join(os.getcwd(), name) path = g.prompt( "Project Path", default_project_path, "This is the path where the project will be located. You can " "move a project around later if you do not like the path. If " "you provide a relative path it will be relative to the working " "directory.", ) path = os.path.expanduser(path) with_blog = g.prompt( "Add Basic Blog", True, "Do you want to generate a basic blog module? If you enable this " "the models for a very basic blog will be generated.", ) g.confirm("That's all. Create project?") g.run( { "project_name": name, "project_slug": slugify(name), "project_path": path, "with_blog": with_blog, "this_year": datetime.utcnow().year, "today": datetime.utcnow().strftime("%Y-%m-%d"), "author_name": author_name, }, path, )
25,788
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/quickstart.py
plugin_quickstart
(defaults=None, project=None)
235
295
def plugin_quickstart(defaults=None, project=None): if defaults is None: defaults = {} g = Generator("plugin") plugin_name = defaults.get("plugin_name") if plugin_name is None: plugin_name = g.prompt( "Plugin Name", default=None, info="This is the human readable name for this plugin", ) plugin_id = plugin_name.lower() if plugin_id.startswith("lektor"): plugin_id = plugin_id[6:] if plugin_id.endswith("plugin"): plugin_id = plugin_id[:-6] plugin_id = slugify(plugin_id) path = defaults.get("path") if path is None: if project is not None: default_path = os.path.join(project.tree, "packages", plugin_id) else: if len(os.listdir(".")) == 0: default_path = os.getcwd() else: default_path = os.path.join(os.getcwd(), plugin_id) path = g.prompt( "Plugin Path", default_path, "The place where you want to initialize the plugin", ) author_name = g.prompt( "Author Name", get_default_author(), "Your name as it will be embedded in the plugin metadata.", ) author_email = g.prompt( "Author E-Mail", get_default_author_email(), "Your e-mail address for the plugin info.", ) g.confirm("Create Plugin?") g.run( { "plugin_name": plugin_name, "plugin_id": plugin_id, "plugin_class": plugin_id.title().replace("-", "") + "Plugin", "plugin_module": "lektor_" + plugin_id.replace("-", "_"), "author_name": author_name, "author_email": author_email, }, path, )
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/quickstart.py#L235-L295
40
[ 0 ]
1.639344
[ 1, 2, 4, 6, 7, 8, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 26, 27, 29, 30, 36, 42, 48, 50 ]
39.344262
false
23.5
61
8
60.655738
0
def plugin_quickstart(defaults=None, project=None): if defaults is None: defaults = {} g = Generator("plugin") plugin_name = defaults.get("plugin_name") if plugin_name is None: plugin_name = g.prompt( "Plugin Name", default=None, info="This is the human readable name for this plugin", ) plugin_id = plugin_name.lower() if plugin_id.startswith("lektor"): plugin_id = plugin_id[6:] if plugin_id.endswith("plugin"): plugin_id = plugin_id[:-6] plugin_id = slugify(plugin_id) path = defaults.get("path") if path is None: if project is not None: default_path = os.path.join(project.tree, "packages", plugin_id) else: if len(os.listdir(".")) == 0: default_path = os.getcwd() else: default_path = os.path.join(os.getcwd(), plugin_id) path = g.prompt( "Plugin Path", default_path, "The place where you want to initialize the plugin", ) author_name = g.prompt( "Author Name", get_default_author(), "Your name as it will be embedded in the plugin metadata.", ) author_email = g.prompt( "Author E-Mail", get_default_author_email(), "Your e-mail address for the plugin info.", ) g.confirm("Create Plugin?") g.run( { "plugin_name": plugin_name, "plugin_id": plugin_id, "plugin_class": plugin_id.title().replace("-", "") + "Plugin", "plugin_module": "lektor_" + plugin_id.replace("-", "_"), "author_name": author_name, "author_email": author_email, }, path, )
25,789
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/quickstart.py
theme_quickstart
(defaults=None, project=None)
298
395
def theme_quickstart(defaults=None, project=None): if defaults is None: defaults = {} g = Generator("theme") theme_name = defaults.get("theme_name") if theme_name is None: theme_name = g.prompt( "Theme Name", default=None, info="This is the human readable name for this theme", ) theme_id = theme_name.lower() if theme_id != "lektor" and theme_id.startswith("lektor"): theme_id = theme_id[6:].strip() if theme_id != "theme" and theme_id.startswith("theme"): theme_id = theme_id[5:] if theme_id != "theme" and theme_id.endswith("theme"): theme_id = theme_id[:-5] theme_id = slugify(theme_id) path = defaults.get("path") if path is None: if project is not None: default_path = os.path.join( project.tree, "themes", "lektor-theme-{}".format(theme_id) ) else: if len(os.listdir(".")) == 0: default_path = os.getcwd() else: default_path = os.path.join(os.getcwd(), theme_id) path = g.prompt( "Theme Path", default_path, "The place where you want to initialize the theme", ) author_name = g.prompt( "Author Name", get_default_author(), "Your name as it will be embedded in the theme metadata.", ) author_email = g.prompt( "Author E-Mail", get_default_author_email(), "Your e-mail address for the theme info.", ) g.confirm("Create Theme?") g.run( { "theme_name": theme_name, "theme_id": theme_id, "author_name": author_name, "author_email": author_email, }, path, ) # symlink theme_dir = os.getcwd() example_themes = os.path.join(path, "example-site/themes") os.makedirs(example_themes) os.chdir(example_themes) try: os.symlink( "../../../lektor-theme-{}".format(theme_id), "lektor-theme-{}".format(theme_id), ) except OSError as exc: # Windows, by default, only allows members of the "Administrators" group # to create symlinks. For users who are not allowed to create symlinks, # error Code 1314 - "A required privilege is not held by the client" # is raised. if getattr(exc, "winerror", None) != 1314: raise g.warn( "Could not automatically make a symlink to have your example-site" "easily pick up your theme." ) os.chdir(theme_dir) # Sample image os.makedirs(os.path.join(path, "images")) source_image_path = os.path.join( os.path.dirname(os.path.realpath(__file__)), "quickstart-templates/theme/images/homepage.png", ) destination_image_path = os.path.join(path, "images/homepage.png") with open(source_image_path, "rb") as f: image = f.read() with open(destination_image_path, "wb") as f: f.write(image)
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/quickstart.py#L298-L395
40
[ 0 ]
1.020408
[ 1, 2, 4, 6, 7, 8, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 30, 31, 33, 34, 40, 46, 52, 54, 65, 66, 67, 68, 69, 70, 74, 79, 80, 81, 85, 88, 89, 93, 94, 95, 96, 97 ]
44.897959
false
23.5
98
16
55.102041
0
def theme_quickstart(defaults=None, project=None): if defaults is None: defaults = {} g = Generator("theme") theme_name = defaults.get("theme_name") if theme_name is None: theme_name = g.prompt( "Theme Name", default=None, info="This is the human readable name for this theme", ) theme_id = theme_name.lower() if theme_id != "lektor" and theme_id.startswith("lektor"): theme_id = theme_id[6:].strip() if theme_id != "theme" and theme_id.startswith("theme"): theme_id = theme_id[5:] if theme_id != "theme" and theme_id.endswith("theme"): theme_id = theme_id[:-5] theme_id = slugify(theme_id) path = defaults.get("path") if path is None: if project is not None: default_path = os.path.join( project.tree, "themes", "lektor-theme-{}".format(theme_id) ) else: if len(os.listdir(".")) == 0: default_path = os.getcwd() else: default_path = os.path.join(os.getcwd(), theme_id) path = g.prompt( "Theme Path", default_path, "The place where you want to initialize the theme", ) author_name = g.prompt( "Author Name", get_default_author(), "Your name as it will be embedded in the theme metadata.", ) author_email = g.prompt( "Author E-Mail", get_default_author_email(), "Your e-mail address for the theme info.", ) g.confirm("Create Theme?") g.run( { "theme_name": theme_name, "theme_id": theme_id, "author_name": author_name, "author_email": author_email, }, path, ) # symlink theme_dir = os.getcwd() example_themes = os.path.join(path, "example-site/themes") os.makedirs(example_themes) os.chdir(example_themes) try: os.symlink( "../../../lektor-theme-{}".format(theme_id), "lektor-theme-{}".format(theme_id), ) except OSError as exc: # Windows, by default, only allows members of the "Administrators" group # to create symlinks. For users who are not allowed to create symlinks, # error Code 1314 - "A required privilege is not held by the client" # is raised. if getattr(exc, "winerror", None) != 1314: raise g.warn( "Could not automatically make a symlink to have your example-site" "easily pick up your theme." ) os.chdir(theme_dir) # Sample image os.makedirs(os.path.join(path, "images")) source_image_path = os.path.join( os.path.dirname(os.path.realpath(__file__)), "quickstart-templates/theme/images/homepage.png", ) destination_image_path = os.path.join(path, "images/homepage.png") with open(source_image_path, "rb") as f: image = f.read() with open(destination_image_path, "wb") as f: f.write(image)
25,790
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/quickstart.py
Generator.__init__
(self, base)
28
45
def __init__(self, base): self.question = 0 self.jinja_env = Environment( loader=PackageLoader("lektor", "quickstart-templates/%s" % base), line_statement_prefix="%%", line_comment_prefix="##", variable_start_string="${", variable_end_string="}", block_start_string="<%", block_end_string="%>", comment_start_string="/**", comment_end_string="**/", ) self.options = {} # term width in [1, 78] self.term_width = min(max(shutil.get_terminal_size()[0], 1), 78) self.e = click.secho self.w = partial(click.wrap_text, width=self.term_width)
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/quickstart.py#L28-L45
40
[ 0 ]
5.555556
[ 1, 2, 13, 15, 16, 17 ]
33.333333
false
23.5
18
1
66.666667
0
def __init__(self, base): self.question = 0 self.jinja_env = Environment( loader=PackageLoader("lektor", "quickstart-templates/%s" % base), line_statement_prefix="%%", line_comment_prefix="##", variable_start_string="${", variable_end_string="}", block_start_string="<%", block_end_string="%>", comment_start_string="/**", comment_end_string="**/", ) self.options = {} # term width in [1, 78] self.term_width = min(max(shutil.get_terminal_size()[0], 1), 78) self.e = click.secho self.w = partial(click.wrap_text, width=self.term_width)
25,791
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/quickstart.py
Generator.abort
(message)
48
50
def abort(message): click.echo("Error: %s" % message, err=True) raise click.Abort()
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/quickstart.py#L48-L50
40
[ 0 ]
33.333333
[ 1, 2 ]
66.666667
false
23.5
3
1
33.333333
0
def abort(message): click.echo("Error: %s" % message, err=True) raise click.Abort()
25,792
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/quickstart.py
Generator.prompt
(self, text, default=None, info=None)
return click.prompt(text, default=default, show_default=True)
52
62
def prompt(self, text, default=None, info=None): self.question += 1 self.e("") self.e("Step %d:" % self.question, fg="yellow") if info is not None: self.e(click.wrap_text(info, self.term_width, "| ", "| ")) text = "> " + click.style(text, fg="green") if default is True or default is False: return click.confirm(text, default=default) return click.prompt(text, default=default, show_default=True)
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/quickstart.py#L52-L62
40
[ 0 ]
9.090909
[ 1, 2, 3, 4, 5, 6, 8, 9, 10 ]
81.818182
false
23.5
11
4
18.181818
0
def prompt(self, text, default=None, info=None): self.question += 1 self.e("") self.e("Step %d:" % self.question, fg="yellow") if info is not None: self.e(click.wrap_text(info, self.term_width, "| ", "| ")) text = "> " + click.style(text, fg="green") if default is True or default is False: return click.confirm(text, default=default) return click.prompt(text, default=default, show_default=True)
25,793
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/quickstart.py
Generator.title
(self, title)
64
67
def title(self, title): self.e(title, fg="cyan") self.e("=" * len(title), fg="cyan") self.e("")
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/quickstart.py#L64-L67
40
[ 0 ]
25
[ 1, 2, 3 ]
75
false
23.5
4
1
25
0
def title(self, title): self.e(title, fg="cyan") self.e("=" * len(title), fg="cyan") self.e("")
25,794
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/quickstart.py
Generator.warn
(self, text)
69
70
def warn(self, text): self.e(self.w(text), fg="magenta")
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/quickstart.py#L69-L70
40
[ 0 ]
50
[ 1 ]
50
false
23.5
2
1
50
0
def warn(self, text): self.e(self.w(text), fg="magenta")
25,795
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/quickstart.py
Generator.text
(self, text)
72
73
def text(self, text): self.e(self.w(text))
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/quickstart.py#L72-L73
40
[ 0 ]
50
[ 1 ]
50
false
23.5
2
1
50
0
def text(self, text): self.e(self.w(text))
25,796
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/quickstart.py
Generator.confirm
(self, prompt)
75
77
def confirm(self, prompt): self.e("") click.confirm(prompt, default=True, abort=True, prompt_suffix=" ")
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/quickstart.py#L75-L77
40
[ 0 ]
33.333333
[ 1, 2 ]
66.666667
false
23.5
3
1
33.333333
0
def confirm(self, prompt): self.e("") click.confirm(prompt, default=True, abort=True, prompt_suffix=" ")
25,797
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/quickstart.py
Generator.make_target_directory
(self, path)
80
104
def make_target_directory(self, path): here = os.path.abspath(os.getcwd()) path = os.path.abspath(path) if here != path: try: os.makedirs(path) except OSError as e: self.abort("Could not create target folder: %s" % e) if os.path.isdir(path): try: if len(os.listdir(path)) != 0: raise OSError("Directory not empty") except OSError as e: self.abort("Bad target folder: %s" % e) with TemporaryDirectory() as scratch: yield scratch # Use shutil.move here in case we move across a file system # boundary. for filename in os.listdir(scratch): shutil.move( os.path.join(scratch, filename), os.path.join(path, filename) )
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/quickstart.py#L80-L104
40
[ 0 ]
4
[ 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 16, 17, 21, 22 ]
68
false
23.5
25
8
32
0
def make_target_directory(self, path): here = os.path.abspath(os.getcwd()) path = os.path.abspath(path) if here != path: try: os.makedirs(path) except OSError as e: self.abort("Could not create target folder: %s" % e) if os.path.isdir(path): try: if len(os.listdir(path)) != 0: raise OSError("Directory not empty") except OSError as e: self.abort("Bad target folder: %s" % e) with TemporaryDirectory() as scratch: yield scratch # Use shutil.move here in case we move across a file system # boundary. for filename in os.listdir(scratch): shutil.move( os.path.join(scratch, filename), os.path.join(path, filename) )
25,798
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/quickstart.py
Generator.expand_filename
(base, ctx, template_filename)
return os.path.join(base, _var_re.sub(_repl, template_filename))[:-3]
107
111
def expand_filename(base, ctx, template_filename): def _repl(match): return ctx[match.group(1)] return os.path.join(base, _var_re.sub(_repl, template_filename))[:-3]
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/quickstart.py#L107-L111
40
[ 0 ]
20
[ 1, 2, 4 ]
60
false
23.5
5
2
40
0
def expand_filename(base, ctx, template_filename): def _repl(match): return ctx[match.group(1)] return os.path.join(base, _var_re.sub(_repl, template_filename))[:-3]
25,799
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/quickstart.py
Generator.run
(self, ctx, path)
113
128
def run(self, ctx, path): with self.make_target_directory(path) as scratch: for template in self.jinja_env.list_templates(): if not template.endswith(".in"): continue fn = self.expand_filename(scratch, ctx, template) tmpl = self.jinja_env.get_template(template) rv = tmpl.render(ctx).strip("\r\n") if rv: directory = os.path.dirname(fn) try: os.makedirs(directory) except OSError: pass with open(fn, "wb") as f: f.write((rv + "\n").encode("utf-8"))
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/quickstart.py#L113-L128
40
[ 0 ]
6.25
[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ]
93.75
false
23.5
16
7
6.25
0
def run(self, ctx, path): with self.make_target_directory(path) as scratch: for template in self.jinja_env.list_templates(): if not template.endswith(".in"): continue fn = self.expand_filename(scratch, ctx, template) tmpl = self.jinja_env.get_template(template) rv = tmpl.render(ctx).strip("\r\n") if rv: directory = os.path.dirname(fn) try: os.makedirs(directory) except OSError: pass with open(fn, "wb") as f: f.write((rv + "\n").encode("utf-8"))
25,800
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/editor.py
make_editor_session
(pad, path, is_attachment=None, alt=PRIMARY_ALT, datamodel=None)
return EditorSession( pad, id, str(path), raw_data, raw_data_fallback, datamodel, record, exists, is_attachment, alt, )
Creates an editor session for the given path object.
Creates an editor session for the given path object.
35
102
def make_editor_session(pad, path, is_attachment=None, alt=PRIMARY_ALT, datamodel=None): """Creates an editor session for the given path object.""" if alt != PRIMARY_ALT and not pad.db.config.is_valid_alternative(alt): raise BadEdit("Attempted to edit an invalid alternative (%s)" % alt) raw_data = pad.db.load_raw_data(path, cls=OrderedDict, alt=alt, fallback=False) raw_data_fallback = None if alt != PRIMARY_ALT: raw_data_fallback = pad.db.load_raw_data(path, cls=OrderedDict) all_data = OrderedDict() all_data.update(raw_data_fallback or ()) all_data.update(raw_data or ()) else: all_data = raw_data id = posixpath.basename(path) if not is_valid_id(id): raise BadEdit("Invalid ID") record = None exists = raw_data is not None or raw_data_fallback is not None if raw_data is None: raw_data = OrderedDict() if is_attachment is None: if not exists: is_attachment = False else: is_attachment = bool(all_data.get("_attachment_for")) elif bool(all_data.get("_attachment_for")) != is_attachment: raise BadEdit( "The attachment flag passed is conflicting with the " "record's attachment flag." ) if exists: # XXX: what about changing the datamodel after the fact? if datamodel is not None: raise BadEdit( "When editing an existing record, a datamodel must not be provided." ) datamodel = pad.db.get_datamodel_for_raw_data(all_data, pad) else: if datamodel is None: datamodel = pad.db.get_implied_datamodel(path, is_attachment, pad) elif isinstance(datamodel, str): datamodel = pad.db.datamodels[datamodel] if exists: record = pad.instance_from_data(dict(all_data), datamodel) for key in implied_keys: raw_data.pop(key, None) if raw_data_fallback: raw_data_fallback.pop(key, None) return EditorSession( pad, id, str(path), raw_data, raw_data_fallback, datamodel, record, exists, is_attachment, alt, )
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/editor.py#L35-L102
40
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67 ]
100
[]
0
true
83.125
68
19
100
1
def make_editor_session(pad, path, is_attachment=None, alt=PRIMARY_ALT, datamodel=None): if alt != PRIMARY_ALT and not pad.db.config.is_valid_alternative(alt): raise BadEdit("Attempted to edit an invalid alternative (%s)" % alt) raw_data = pad.db.load_raw_data(path, cls=OrderedDict, alt=alt, fallback=False) raw_data_fallback = None if alt != PRIMARY_ALT: raw_data_fallback = pad.db.load_raw_data(path, cls=OrderedDict) all_data = OrderedDict() all_data.update(raw_data_fallback or ()) all_data.update(raw_data or ()) else: all_data = raw_data id = posixpath.basename(path) if not is_valid_id(id): raise BadEdit("Invalid ID") record = None exists = raw_data is not None or raw_data_fallback is not None if raw_data is None: raw_data = OrderedDict() if is_attachment is None: if not exists: is_attachment = False else: is_attachment = bool(all_data.get("_attachment_for")) elif bool(all_data.get("_attachment_for")) != is_attachment: raise BadEdit( "The attachment flag passed is conflicting with the " "record's attachment flag." ) if exists: # XXX: what about changing the datamodel after the fact? if datamodel is not None: raise BadEdit( "When editing an existing record, a datamodel must not be provided." ) datamodel = pad.db.get_datamodel_for_raw_data(all_data, pad) else: if datamodel is None: datamodel = pad.db.get_implied_datamodel(path, is_attachment, pad) elif isinstance(datamodel, str): datamodel = pad.db.datamodels[datamodel] if exists: record = pad.instance_from_data(dict(all_data), datamodel) for key in implied_keys: raw_data.pop(key, None) if raw_data_fallback: raw_data_fallback.pop(key, None) return EditorSession( pad, id, str(path), raw_data, raw_data_fallback, datamodel, record, exists, is_attachment, alt, )
25,801
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/editor.py
_deprecated_data_proxy
(wrapped)
return wrapper
Issue warning when deprecated mapping methods are used directly on EditorSession.
Issue warning when deprecated mapping methods are used directly on EditorSession.
105
122
def _deprecated_data_proxy(wrapped): """Issue warning when deprecated mapping methods are used directly on EditorSession. """ name = wrapped.__name__ newname = name[4:] if name.startswith("iter") else name @wraps(wrapped) def wrapper(self, *args, **kwargs): warnings.warn( f"EditorSession.{name} has been deprecated as of Lektor 3.3.2. " f"Please use EditorSession.data.{newname} instead.", DeprecationWarning, ) return wrapped(self, *args, **kwargs) return wrapper
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/editor.py#L105-L122
40
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ]
100
[]
0
true
83.125
18
2
100
2
def _deprecated_data_proxy(wrapped): name = wrapped.__name__ newname = name[4:] if name.startswith("iter") else name @wraps(wrapped) def wrapper(self, *args, **kwargs): warnings.warn( f"EditorSession.{name} has been deprecated as of Lektor 3.3.2. " f"Please use EditorSession.data.{newname} instead.", DeprecationWarning, ) return wrapped(self, *args, **kwargs) return wrapper
25,802
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/editor.py
_uniq
(seq)
Return items from iterable in order, skipping items that have already been seen. The items in ``seq`` must be hashable.
Return items from iterable in order, skipping items that have already been seen.
524
533
def _uniq(seq): """Return items from iterable in order, skipping items that have already been seen. The items in ``seq`` must be hashable. """ seen = set() for item in seq: if item not in seen: seen.add(item) yield item
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/editor.py#L524-L533
40
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
100
[]
0
true
83.125
10
3
100
3
def _uniq(seq): seen = set() for item in seq: if item not in seen: seen.add(item) yield item
25,803
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/editor.py
EditorSession.__init__
( self, pad, id, path, original_data, fallback_data, datamodel, record, exists=True, is_attachment=False, alt=PRIMARY_ALT, )
126
168
def __init__( self, pad, id, path, original_data, fallback_data, datamodel, record, exists=True, is_attachment=False, alt=PRIMARY_ALT, ): self.id = id self.pad = pad self.path = path self.record = record self.exists = exists self.datamodel = datamodel self.is_root = path.strip("/") == "" self.alt = alt slug_format = None parent_name = posixpath.dirname(path) if parent_name != path: parent = pad.get(parent_name) if parent is not None: slug_format = parent.datamodel.child_config.slug_format if slug_format is None: slug_format = "{{ this._id }}" self.slug_format = slug_format self.implied_attachment_type = None if is_attachment: self.implied_attachment_type = pad.db.get_attachment_type(path) self.data = MutableEditorData(original_data, fallback_data) self._delete_this = False self._recursive_delete = False self._master_delete = False self.is_attachment = is_attachment self.closed = False
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/editor.py#L126-L168
40
[ 0, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 ]
72.093023
[]
0
false
83.125
43
5
100
0
def __init__( self, pad, id, path, original_data, fallback_data, datamodel, record, exists=True, is_attachment=False, alt=PRIMARY_ALT, ): self.id = id self.pad = pad self.path = path self.record = record self.exists = exists self.datamodel = datamodel self.is_root = path.strip("/") == "" self.alt = alt slug_format = None parent_name = posixpath.dirname(path) if parent_name != path: parent = pad.get(parent_name) if parent is not None: slug_format = parent.datamodel.child_config.slug_format if slug_format is None: slug_format = "{{ this._id }}" self.slug_format = slug_format self.implied_attachment_type = None if is_attachment: self.implied_attachment_type = pad.db.get_attachment_type(path) self.data = MutableEditorData(original_data, fallback_data) self._delete_this = False self._recursive_delete = False self._master_delete = False self.is_attachment = is_attachment self.closed = False
25,804
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/editor.py
EditorSession.to_json
(self)
return { "data": dict(self.data.items()), "record_info": { "id": self.id, "path": self.path, "exists": self.exists, "label": label, "label_i18n": label_i18n, "url_path": url_path, "alt": self.alt, "is_attachment": self.is_attachment, "can_be_deleted": can_be_deleted, "slug_format": self.slug_format, "implied_attachment_type": self.implied_attachment_type, "default_template": self.datamodel.get_default_template_name(), }, "datamodel": self.datamodel.to_json(self.pad, self.record, self.alt), }
170
198
def to_json(self): label = None label_i18n = None url_path = None if self.record is not None: label = self.record.record_label label_i18n = self.record.get_record_label_i18n() url_path = self.record.url_path else: label = self.id can_be_deleted = not self.datamodel.protected and not self.is_root return { "data": dict(self.data.items()), "record_info": { "id": self.id, "path": self.path, "exists": self.exists, "label": label, "label_i18n": label_i18n, "url_path": url_path, "alt": self.alt, "is_attachment": self.is_attachment, "can_be_deleted": can_be_deleted, "slug_format": self.slug_format, "implied_attachment_type": self.implied_attachment_type, "default_template": self.datamodel.get_default_template_name(), }, "datamodel": self.datamodel.to_json(self.pad, self.record, self.alt), }
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/editor.py#L170-L198
40
[ 0, 1, 2, 3, 4, 5, 6, 7, 10, 11 ]
34.482759
[ 9 ]
3.448276
false
83.125
29
3
96.551724
0
def to_json(self): label = None label_i18n = None url_path = None if self.record is not None: label = self.record.record_label label_i18n = self.record.get_record_label_i18n() url_path = self.record.url_path else: label = self.id can_be_deleted = not self.datamodel.protected and not self.is_root return { "data": dict(self.data.items()), "record_info": { "id": self.id, "path": self.path, "exists": self.exists, "label": label, "label_i18n": label_i18n, "url_path": url_path, "alt": self.alt, "is_attachment": self.is_attachment, "can_be_deleted": can_be_deleted, "slug_format": self.slug_format, "implied_attachment_type": self.implied_attachment_type, "default_template": self.datamodel.get_default_template_name(), }, "datamodel": self.datamodel.to_json(self.pad, self.record, self.alt), }
25,805
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/editor.py
EditorSession.__enter__
(self)
return self
200
201
def __enter__(self): return self
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/editor.py#L200-L201
40
[ 0, 1 ]
100
[]
0
true
83.125
2
1
100
0
def __enter__(self): return self
25,806
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/editor.py
EditorSession.__exit__
(self, exc_type, exc_value, tb)
203
207
def __exit__(self, exc_type, exc_value, tb): if exc_type is not None: self.rollback() else: self.commit()
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/editor.py#L203-L207
40
[ 0, 1, 4 ]
60
[ 2 ]
20
false
83.125
5
2
80
0
def __exit__(self, exc_type, exc_value, tb): if exc_type is not None: self.rollback() else: self.commit()
25,807
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/editor.py
EditorSession.get_fs_path
(self, alt=PRIMARY_ALT)
return os.path.join(base, "contents" + suffix)
The path to the record file on the file system.
The path to the record file on the file system.
209
217
def get_fs_path(self, alt=PRIMARY_ALT): """The path to the record file on the file system.""" base = self.pad.db.to_fs_path(self.path) suffix = ".lr" if alt != PRIMARY_ALT: suffix = "+%s%s" % (alt, suffix) if self.is_attachment: return base + suffix return os.path.join(base, "contents" + suffix)
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/editor.py#L209-L217
40
[ 0, 1, 2, 3, 4, 5, 6, 8 ]
88.888889
[ 7 ]
11.111111
false
83.125
9
3
88.888889
1
def get_fs_path(self, alt=PRIMARY_ALT): base = self.pad.db.to_fs_path(self.path) suffix = ".lr" if alt != PRIMARY_ALT: suffix = "+%s%s" % (alt, suffix) if self.is_attachment: return base + suffix return os.path.join(base, "contents" + suffix)
25,808
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/editor.py
EditorSession.fs_path
(self)
return self.get_fs_path(self.alt)
The file system path of the content file on disk.
The file system path of the content file on disk.
220
222
def fs_path(self): """The file system path of the content file on disk.""" return self.get_fs_path(self.alt)
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/editor.py#L220-L222
40
[ 0, 1, 2 ]
100
[]
0
true
83.125
3
1
100
1
def fs_path(self): return self.get_fs_path(self.alt)
25,809
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/editor.py
EditorSession.attachment_fs_path
(self)
return None
The file system path of the actual attachment.
The file system path of the actual attachment.
225
229
def attachment_fs_path(self): """The file system path of the actual attachment.""" if self.is_attachment: return self.pad.db.to_fs_path(self.path) return None
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/editor.py#L225-L229
40
[ 0, 1 ]
40
[ 2, 3, 4 ]
60
false
83.125
5
2
40
1
def attachment_fs_path(self): if self.is_attachment: return self.pad.db.to_fs_path(self.path) return None
25,810
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/editor.py
EditorSession.rollback
(self)
Ignores all changes and rejects them.
Ignores all changes and rejects them.
231
235
def rollback(self): """Ignores all changes and rejects them.""" if self.closed: return self.closed = True
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/editor.py#L231-L235
40
[ 0, 1 ]
40
[ 2, 3, 4 ]
60
false
83.125
5
2
40
1
def rollback(self): if self.closed: return self.closed = True
25,811
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/editor.py
EditorSession.commit
(self)
Saves changes back to the file system.
Saves changes back to the file system.
237
244
def commit(self): """Saves changes back to the file system.""" if not self.closed: if self._delete_this: self._delete_impl() else: self._save_impl() self.closed = True
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/editor.py#L237-L244
40
[ 0, 1, 2, 3, 5, 6, 7 ]
87.5
[ 4 ]
12.5
false
83.125
8
3
87.5
1
def commit(self): if not self.closed: if self._delete_this: self._delete_impl() else: self._save_impl() self.closed = True
25,812
lektor/lektor
74bce9096116caffe27ab69327ed4ba274e66e1e
lektor/editor.py
EditorSession.delete
(self, recursive=None, delete_master=False)
Deletes the record. How the delete works depends on what is being deleted: * delete attachment: recursive mode is silently ignored. If `delete_master` is set then the attachment is deleted, otherwise only the metadata is deleted. * delete page: in recursive mode everything is deleted in which case `delete_master` must be set to `True` or an error is generated. In fact, the default is to perform a recursive delete in that case. If `delete_master` is False, then only the contents file of the current alt is deleted. If a delete cannot be performed, an error is generated.
Deletes the record. How the delete works depends on what is being deleted:
246
267
def delete(self, recursive=None, delete_master=False): """Deletes the record. How the delete works depends on what is being deleted: * delete attachment: recursive mode is silently ignored. If `delete_master` is set then the attachment is deleted, otherwise only the metadata is deleted. * delete page: in recursive mode everything is deleted in which case `delete_master` must be set to `True` or an error is generated. In fact, the default is to perform a recursive delete in that case. If `delete_master` is False, then only the contents file of the current alt is deleted. If a delete cannot be performed, an error is generated. """ if self.closed: return if recursive is None: recursive = not self.is_attachment and delete_master self._delete_this = True self._recursive_delete = recursive self._master_delete = delete_master
https://github.com/lektor/lektor/blob/74bce9096116caffe27ab69327ed4ba274e66e1e/project40/lektor/editor.py#L246-L267
40
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 ]
68.181818
[ 15, 16, 17, 18, 19, 20, 21 ]
31.818182
false
83.125
22
4
68.181818
13
def delete(self, recursive=None, delete_master=False): if self.closed: return if recursive is None: recursive = not self.is_attachment and delete_master self._delete_this = True self._recursive_delete = recursive self._master_delete = delete_master
25,813