_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q247800 | Compiler.compile | train | def compile(self, source, path=None):
"""Compile source to a ready to run template.
:param source:
The template to compile - should be a unicode string
:return:
A template function ready to execute
"""
container = self._generate_code(source)
de... | python | {
"resource": ""
} |
q247801 | Compiler.clean_whitespace | train | def clean_whitespace(self, tree):
"""
Cleans up whitespace around block open and close tags if they are the
only thing on the line
:param tree:
The AST - will be modified in place
"""
pointer = 0
end = len(tree)
while pointer < end:
... | python | {
"resource": ""
} |
q247802 | _default_conflict_solver | train | def _default_conflict_solver(match, conflicting_match):
"""
Default conflict solver for matches, shorter matches if they conflicts with longer ones
:param conflicting_match:
:type conflicting_match:
| python | {
"resource": ""
} |
q247803 | call | train | def call(function, *args, **kwargs):
"""
Call a function or constructor with given args and kwargs after removing args and kwargs that doesn't match
function or constructor signature
:param function: Function or constructor to call
:type function: callable
:param args:
:type args:
:para... | python | {
"resource": ""
} |
q247804 | ensure_dict | train | def ensure_dict(param, default_value, default_key=None):
"""
Retrieves a dict and a default value from given parameter.
if parameter is not a dict, it will be promoted as the default value.
:param param:
:type param:
:param default_value:
:type default_value:
:param default_key:
:t... | python | {
"resource": ""
} |
q247805 | filter_index | train | def filter_index(collection, predicate=None, index=None):
"""
Filter collection with predicate function and index.
If index is not found, returns None.
:param collection:
:type collection: collection supporting iteration and slicing
:param predicate: function to filter the collection with
:... | python | {
"resource": ""
} |
q247806 | Rules.load | train | def load(self, *rules):
"""
Load rules from a Rule module, class or instance
:param rules:
:type rules:
:return:
:rtype:
"""
for rule in rules:
if inspect.ismodule(rule):
| python | {
"resource": ""
} |
q247807 | Rules.load_module | train | def load_module(self, module):
"""
Load a rules module
:param module:
:type module:
:return:
:rtype:
"""
# pylint: disable=unused-variable
for name, obj in inspect.getmembers(module,
lambda member: hasat... | python | {
"resource": ""
} |
q247808 | Rules.execute_all_rules | train | def execute_all_rules(self, matches, context):
"""
Execute all rules from this rules list. All when condition with same priority will be performed before
calling then actions.
:param matches:
:type matches:
:param context:
:type context:
:return:
... | python | {
"resource": ""
} |
q247809 | _BaseMatches.at_match | train | def at_match(self, match, predicate=None, index=None):
"""
Retrieves a | python | {
"resource": ""
} |
q247810 | _BaseMatches.at_index | train | def at_index(self, pos, predicate=None, index=None):
"""
Retrieves a list of matches from given position
"""
| python | {
"resource": ""
} |
q247811 | Match.children | train | def children(self):
"""
Children matches.
"""
if self._children | python | {
"resource": ""
} |
q247812 | filter_match_kwargs | train | def filter_match_kwargs(kwargs, children=False):
"""
Filters out kwargs for Match construction
:param kwargs:
:type kwargs: dict
:param children:
:type children: Flag to filter children matches
:return: A filtered dict
:rtype: dict
"""
kwargs = kwargs.copy()
for key in ('pat... | python | {
"resource": ""
} |
q247813 | chars_before | train | def chars_before(chars, match):
"""
Validate the match if left character is in a given sequence.
:param chars:
:type chars:
:param match:
:type match:
:return:
:rtype:
"""
| python | {
"resource": ""
} |
q247814 | chars_after | train | def chars_after(chars, match):
"""
Validate the match if right character is in a given sequence.
:param chars:
:type chars:
| python | {
"resource": ""
} |
q247815 | validators | train | def validators(*chained_validators):
"""
Creates a validator chain from several validator functions.
:param chained_validators:
:type chained_validators:
:return:
:rtype:
"""
def validator_chain(match): # | python | {
"resource": ""
} |
q247816 | Rebulk.build_re | train | def build_re(self, *pattern, **kwargs):
"""
Builds a new regular expression pattern
:param pattern:
:type pattern:
:param kwargs:
:type kwargs:
:return:
:rtype:
| python | {
"resource": ""
} |
q247817 | Rebulk.build_string | train | def build_string(self, *pattern, **kwargs):
"""
Builds a new string pattern
:param pattern:
:type pattern:
:param kwargs:
:type kwargs:
:return:
:rtype:
| python | {
"resource": ""
} |
q247818 | Rebulk.build_functional | train | def build_functional(self, *pattern, **kwargs):
"""
Builds a new functional pattern
:param pattern:
:type pattern:
:param kwargs:
:type kwargs:
:return:
:rtype:
| python | {
"resource": ""
} |
q247819 | Rebulk.chain | train | def chain(self, **kwargs):
"""
Add patterns chain, using configuration of this rebulk
:param pattern:
:type pattern:
:param kwargs:
:type kwargs:
:return:
| python | {
"resource": ""
} |
q247820 | Rebulk.build_chain | train | def build_chain(self, **kwargs):
"""
Builds a new patterns chain
:param pattern:
:type pattern:
:param kwargs:
:type kwargs:
:return:
:rtype:
| python | {
"resource": ""
} |
q247821 | Chain.chain | train | def chain(self):
"""
Add patterns chain, using configuration from this chain
:return:
:rtype:
"""
# pylint: disable=protected-access
chain = self.rebulk.chain(**self._kwargs)
chain._defaults = dict(self._defaults)
| python | {
"resource": ""
} |
q247822 | ChainPart.repeater | train | def repeater(self, value):
"""
Define the repeater of the current chain part.
:param value:
:type value:
:return:
:rtype:
"""
try:
value = int(value)
self.repeater_start = value
self.repeater_end = value
ret... | python | {
"resource": ""
} |
q247823 | delete_attachment | train | def delete_attachment(request, link_field=None, uri=None):
"""Delete existing file and link."""
if link_field is None:
link_field = "record_uri"
if uri is None:
uri = record_uri(request)
# Remove file.
filters = [Filter(link_field, uri, core_utils.COMPARISON.EQ)]
storage = reque... | python | {
"resource": ""
} |
q247824 | on_delete_record | train | def on_delete_record(event):
"""When a resource record is deleted, delete all related attachments.
When a bucket or collection is deleted, it removes the attachments of
every underlying records.
"""
keep_old_files = asbool(utils.setting_value(event.request, 'keep_old_files', default=False)) | python | {
"resource": ""
} |
q247825 | RinohBuilder.preprocess_tree | train | def preprocess_tree(self, tree):
"""Transform internal refuri targets in reference nodes to refids and
transform footnote rubrics so that they do not end up | python | {
"resource": ""
} |
q247826 | Table._vertically_size_cells | train | def _vertically_size_cells(rendered_rows):
"""Grow row heights to cater for vertically spanned cells that do not
fit in the available space."""
for r, rendered_row in enumerate(rendered_rows):
for rendered_cell in rendered_row:
if rendered_cell.rowspan > 1:
... | python | {
"resource": ""
} |
q247827 | Table._place_rows_and_render_borders | train | def _place_rows_and_render_borders(container, rendered_rows):
"""Place the rendered cells onto the page canvas and draw borders around
them."""
def draw_cell_border(rendered_cell, cell_height, container):
cell_width = rendered_cell.width
background = TableCellBackground((... | python | {
"resource": ""
} |
q247828 | TableRow.get_rowspanned_columns | train | def get_rowspanned_columns(self):
"""Return a dictionary mapping column indices to the number of columns
spanned."""
spanned_columns = {}
current_row_index = self._index
current_row_cols = sum(cell.colspan for cell in self)
prev_rows = iter(reversed(self.section[:current_... | python | {
"resource": ""
} |
q247829 | romanize | train | def romanize(number):
"""Convert `number` to a Roman numeral."""
roman = []
for numeral, | python | {
"resource": ""
} |
q247830 | Container.render | train | def render(self, type, rerender=False):
"""Render the contents of this container to its canvas.
Note that the rendered contents need to be :meth:`place`d on the parent
container's canvas | python | {
"resource": ""
} |
q247831 | Container.place | train | def place(self):
"""Place this container's canvas onto the parent container's canvas."""
| python | {
"resource": ""
} |
q247832 | FlowablesContainerBase.advance2 | train | def advance2(self, height, ignore_overflow=False):
"""Advance the cursor by `height`. Returns `True` on success.
Returns `False` if this would cause the cursor to point beyond the
bottom of the container.
"""
if height <= self.remaining_height:
| python | {
"resource": ""
} |
q247833 | Chain.render | train | def render(self, container, rerender=False):
"""Flow the flowables into the containers that have been added to this
chain."""
if rerender:
container.clear()
if not self._rerendering:
# restore saved state on this chain's 1st container on this page
... | python | {
"resource": ""
} |
q247834 | AttributesDictionary._get_default | train | def _get_default(cls, attribute):
"""Return the default value for `attribute`.
If no default is specified in this style, get the default from the
nearest superclass.
If `attribute` is not supported, raise a | python | {
"resource": ""
} |
q247835 | get_pygments_style | train | def get_pygments_style(style):
"""Retrieve a Pygments style by name, by import path or, if `style` is
already Pygments style, simply return it."""
if isinstance(style, StyleMeta):
return style
if '.' in style: # by python package/module
module, name = style.rsplit('.', 1)
return... | python | {
"resource": ""
} |
q247836 | Flowable.flow | train | def flow(self, container, last_descender, state=None, **kwargs):
"""Flow this flowable into `container` and return the vertical space
consumed.
The flowable's contents is preceded by a vertical space with a height
as specified in its style's `space_above` attribute. Similarly, the
... | python | {
"resource": ""
} |
q247837 | entry_point_name_to_identifier | train | def entry_point_name_to_identifier(entry_point_name):
"""Transform an entry point name into an identifier suitable for inclusion
in a PyPI package name."""
try:
entry_point_name.encode('ascii')
ascii_name = entry_point_name
except UnicodeEncodeError:
| python | {
"resource": ""
} |
q247838 | ParagraphBase.render | train | def render(self, container, descender, state, space_below=0,
first_line_only=False):
"""Typeset the paragraph
The paragraph is typeset in the given container starting below the
current cursor position of the container. When the end of the container
is reached, the renderi... | python | {
"resource": ""
} |
q247839 | Line.typeset | train | def typeset(self, container, text_align, last_line=False):
"""Typeset the line in `container` below its current cursor position.
Advances the container's cursor to below the descender of this line.
`justification` and `line_spacing` are passed on from the paragraph
style. `last_descende... | python | {
"resource": ""
} |
q247840 | create_destination | train | def create_destination(flowable, container, at_top_of_container=False):
"""Create a destination anchor in the `container` to direct links to
`flowable` to."""
vertical_position = 0 if at_top_of_container else container.cursor
ids = flowable.get_ids(container.document)
destination = NamedDestination(... | python | {
"resource": ""
} |
q247841 | DocumentElement.source | train | def source(self):
"""The source element this document element was created from."""
if self._source is not | python | {
"resource": ""
} |
q247842 | DocumentElement.prepare | train | def prepare(self, flowable_target):
"""Determine number labels and register references with the document"""
| python | {
"resource": ""
} |
q247843 | DocumentElement.warn | train | def warn(self, message, container=None):
"""Present the warning `message` to the user, adding information on the
location of the related element in the input file."""
if self.source is not None:
message = '[{}] '.format(self.source.location) + message
if container is not None... | python | {
"resource": ""
} |
q247844 | all_subclasses | train | def all_subclasses(cls):
"""Generator yielding all subclasses of `cls` recursively"""
for subcls in cls.__subclasses__():
yield subcls
| python | {
"resource": ""
} |
q247845 | intersperse | train | def intersperse(iterable, element):
"""Generator yielding all elements of `iterable`, but with `element`
inserted between each two consecutive elements"""
iterable = iter(iterable)
yield next(iterable)
| python | {
"resource": ""
} |
q247846 | unique | train | def unique(iterable):
"""Filter out duplicate items from an iterable"""
seen = set()
for item in iterable:
| python | {
"resource": ""
} |
q247847 | cached | train | def cached(function):
"""Method decorator caching a method's returned values."""
cache_variable = '_cached_' + function.__name__
@wraps(function)
def function_wrapper(obj, *args, **kwargs):
# values are cached in a dict stored in the object
try:
cache = getattr(obj, cache_var... | python | {
"resource": ""
} |
q247848 | cached_generator | train | def cached_generator(function):
"""Method decorator caching a generator's yielded items."""
cache_variable = '_cached_' + function.__name__
@wraps(function)
def function_wrapper(obj, *args, **kwargs):
# values are cached in a list stored in the object
try:
for item in getattr... | python | {
"resource": ""
} |
q247849 | timed | train | def timed(function):
"""Decorator timing the method call and printing the result to `stdout`"""
@wraps(function)
def function_wrapper(obj, *args, **kwargs):
"""Wrapper function printing the time taken by the call to `function`"""
name = obj.__class__.__name__ + '.' + function.__name__
... | python | {
"resource": ""
} |
q247850 | Hyphenator.positions | train | def positions(self, word):
"""
Returns a list of positions where the word can be hyphenated.
See also Hyph_dict.positions. The points that are too far to
the left or right are removed.
"""
| python | {
"resource": ""
} |
q247851 | Hyphenator.iterate | train | def iterate(self, word):
"""
Iterate over all hyphenation possibilities, the longest first.
"""
for p in reversed(self.positions(word)):
if p.data:
# get the nonstandard hyphenation data
| python | {
"resource": ""
} |
q247852 | Hyphenator.wrap | train | def wrap(self, word, width, hyphen='-'):
"""
Return the longest possible first part and the last part of the
hyphenated word. The first part has the hyphen already attached.
Returns None, if there is no hyphenation point before width, or
if the word could not be hyphenated.
| python | {
"resource": ""
} |
q247853 | Hyphenator.inserted | train | def inserted(self, word, hyphen='-'):
"""
Returns the word as a string with all the possible hyphens inserted.
E.g. for the dutch word 'lettergrepen' this method returns
the string 'let-ter-gre-pen'. The hyphen string to use can be
given as the second parameter, that defaults to ... | python | {
"resource": ""
} |
q247854 | Document.render | train | def render(self, filename_root=None, file=None):
"""Render the document repeatedly until the output no longer changes due
to cross-references that need some iterations to converge."""
self.error = False
filename_root = Path(filename_root) if filename_root else None
if filename_ro... | python | {
"resource": ""
} |
q247855 | Document.create_outlines | train | def create_outlines(self):
"""Create an outline in the output file that allows for easy navigation
of the document. The outline is a hierarchical tree of all the sections
in the document."""
sections = parent = []
current_level = 1
stack = []
fake_container = Fake... | python | {
"resource": ""
} |
q247856 | Document._render_pages | train | def _render_pages(self):
"""Render the complete document once and return the number of pages
rendered."""
self.style_log = StyleLog(self.stylesheet)
self.floats = set()
self.placed_footnotes = set()
self._start_time = time.time()
part_page_counts = {}
par... | python | {
"resource": ""
} |
q247857 | htmlhelp | train | def htmlhelp():
"""make HTML files and a HTML help project"""
build('htmlhelp', 'Now you can run HTML Help Workshop with the .hhp '
'project file in {}.')
print('Running HTML Help Workshop...')
| python | {
"resource": ""
} |
q247858 | latexpdf | train | def latexpdf():
"""make LaTeX files and run them through pdflatex"""
rc = latex()
print('Running LaTeX files through pdflatex...') | python | {
"resource": ""
} |
q247859 | info | train | def info():
"""make Texinfo files and run them through makeinfo"""
rc = texinfo()
print('Running Texinfo files through makeinfo...')
builddir = os.path.join(BUILDDIR, 'texinfo') | python | {
"resource": ""
} |
q247860 | help | train | def help():
"""List all targets"""
print("Please use '{} <target>' where <target> is one of"
.format(sys.argv[0]))
width = max(len(name) for name in TARGETS)
for name, target in TARGETS.items():
| python | {
"resource": ""
} |
q247861 | Typeface.fonts | train | def fonts(self):
"""Generator yielding all fonts of this typeface
Yields:
Font: the next font in this typeface
"""
for width in (w for w in FontWidth if w in self):
for slant in (s for s in FontSlant if s in self[width]):
| python | {
"resource": ""
} |
q247862 | Typeface.get_font | train | def get_font(self, weight='medium', slant='upright', width='normal'):
"""Return the font matching or closest to the given style
If a font with the given weight, slant and width is available, return
it. Otherwise, return the font that is closest in style.
Args:
weight (FontW... | python | {
"resource": ""
} |
q247863 | StyleSheet.get_selector | train | def get_selector(self, name):
"""Find a selector mapped to a style in this or a base style sheet.
Args:
name (str): a style name
Returns:
:class:`.Selector`: the selector mapped to the style `name`
Raises:
KeyError: if the style `name` was not found... | python | {
"resource": ""
} |
q247864 | CharIterator.match | train | def match(self, chars):
"""Return all next characters that are listed in `chars` as a string"""
start_index = self.next_index
for char in self:
if char not in chars:
| python | {
"resource": ""
} |
q247865 | _rel_import | train | def _rel_import(module, tgt):
"""Using relative import in both Python 2 and Python 3"""
try:
exec("from ." + module + " import " + tgt, globals(), locals())
except SyntaxError:
# On Python | python | {
"resource": ""
} |
q247866 | peekiter | train | def peekiter(iterable):
"""Return first row and also iterable with same items as original"""
it = iter(iterable)
one = next(it)
def gen():
"""Generator | python | {
"resource": ""
} |
q247867 | check_sizes | train | def check_sizes(size, width, height):
"""
Check that these arguments, in supplied, are consistent.
Return a (width, height) pair.
"""
if not size:
return width, height
if len(size) != 2:
raise ValueError(
"size argument should be a pair (width, height)")
if width ... | python | {
"resource": ""
} |
q247868 | check_color | train | def check_color(c, greyscale, which):
"""
Checks that a colour argument is the right form.
Returns the colour
(which, if it's a bar integer, is "corrected" to a 1-tuple).
For transparent or background options.
"""
if c is None:
return c
if greyscale:
try:
len... | python | {
"resource": ""
} |
q247869 | check_time | train | def check_time(value):
"""Convert time from most popular representations to datetime"""
if value is None:
return None
if isinstance(value, (time.struct_time, tuple)):
return value
if isinstance(value, datetime.datetime):
return value.timetuple()
if isinstance(value, datetime.... | python | {
"resource": ""
} |
q247870 | try_greyscale | train | def try_greyscale(pixels, alpha=False, dirty_alpha=True):
"""
Check if flatboxed RGB `pixels` could be converted to greyscale
If could - return iterator with greyscale pixels,
otherwise return `False` constant
"""
planes = 3 + bool(alpha)
| python | {
"resource": ""
} |
q247871 | adapt_sum | train | def adapt_sum(line, cfg, filter_obj):
"""Determine best filter by sum of all row values"""
lines = filter_obj.filter_all(line)
| python | {
"resource": ""
} |
q247872 | adapt_entropy | train | def adapt_entropy(line, cfg, filter_obj):
"""Determine best filter by dispersion of row values"""
lines = filter_obj.filter_all(line)
| python | {
"resource": ""
} |
q247873 | BaseFilter.__do_filter_sub | train | def __do_filter_sub(self, scanline, result):
"""Sub filter."""
ai = 0
for i in range(self.fu, len(result)):
x = scanline[i] | python | {
"resource": ""
} |
q247874 | BaseFilter.__do_filter_up | train | def __do_filter_up(self, scanline, result):
"""Up filter."""
previous = self.prev
for i in range(len(result)):
| python | {
"resource": ""
} |
q247875 | BaseFilter.__undo_filter_average | train | def __undo_filter_average(self, scanline):
"""Undo average filter."""
ai = -self.fu
previous = self.prev
for i in range(len(scanline)):
x = scanline[i]
if ai < 0:
a = 0
else:
| python | {
"resource": ""
} |
q247876 | BaseFilter.undo_filter | train | def undo_filter(self, filter_type, line):
"""
Undo the filter for a scanline.
`scanline` is a sequence of bytes that does not include
the initial filter type byte.
The scanline will have the effects of filtering removed.
Scanline modified inplace and also returned as re... | python | {
"resource": ""
} |
q247877 | BaseFilter._filter_scanline | train | def _filter_scanline(self, filter_type, line, result):
"""
Apply a scanline filter to a scanline.
`filter_type` specifies the filter type (0 to 4)
'line` specifies the current (unfiltered) scanline as a sequence
of bytes;
"""
assert 0 <= filter_type < 5
i... | python | {
"resource": ""
} |
q247878 | BaseFilter.convert_la_to_rgba | train | def convert_la_to_rgba(self, row, result):
"""Convert a grayscale image with alpha to RGBA."""
for i in range(len(row) // 3):
for j in range(3):
| python | {
"resource": ""
} |
q247879 | BaseFilter.convert_l_to_rgba | train | def convert_l_to_rgba(self, row, result):
"""
Convert a grayscale image to RGBA.
This method assumes the alpha channel in result is already
correctly initialized.
"""
for i in | python | {
"resource": ""
} |
q247880 | BaseFilter.convert_rgb_to_rgba | train | def convert_rgb_to_rgba(self, row, result):
"""
Convert an RGB image to RGBA.
This method assumes the alpha channel in | python | {
"resource": ""
} |
q247881 | Writer.set_icc_profile | train | def set_icc_profile(self, profile=None, name='ICC Profile'):
"""
Add ICC Profile.
Prefered way is tuple (`profile_name`, `profile_bytes`), but only
bytes with name as separate argument is also supported.
"""
if isinstance(profile, (basestring, bytes)):
icc_pr... | python | {
"resource": ""
} |
q247882 | Writer.set_text | train | def set_text(self, text=None, **kwargs):
"""
Add textual information passed as dictionary.
All pairs in dictionary will be written, but keys should be latin-1;
registered keywords could be used as arguments.
When called more than once overwrite exist data.
"""
i... | python | {
"resource": ""
} |
q247883 | Writer.set_modification_time | train | def set_modification_time(self, modification_time=True):
"""
Add time to be written as last modification time
When called after initialisation configure to use
time of writing file
"""
if (isinstance(modification_time, basestring) and
| python | {
"resource": ""
} |
q247884 | Writer.set_resolution | train | def set_resolution(self, resolution=None):
"""
Add physical pixel dimensions
`resolution` supposed two be tuple of two parameterts: pixels per unit
and unit type; unit type may be omitted
pixels per unit could be simple integer or tuple of (ppu_x, ppu_y)
Also possible to... | python | {
"resource": ""
} |
q247885 | Writer.set_rendering_intent | train | def set_rendering_intent(self, rendering_intent):
"""Set rendering intent variant for sRGB chunk"""
if rendering_intent not in (None,
PERCEPTUAL,
RELATIVE_COLORIMETRIC,
| python | {
"resource": ""
} |
q247886 | Writer.set_white_point | train | def set_white_point(self, white_point, point2=None):
"""Set white point part of cHRM chunk"""
if isinstance(white_point, float) and isinstance(point2, float):
| python | {
"resource": ""
} |
q247887 | Writer.set_rgb_points | train | def set_rgb_points(self, rgb_points, *args):
"""Set rgb points part of cHRM chunk"""
if not args:
self.rgb_points = rgb_points
# separate tuples
elif len(args) == 2:
self.rgb_points = (rgb_points, args[0], args[1])
# separate numbers
| python | {
"resource": ""
} |
q247888 | Writer.__write_palette | train | def __write_palette(self, outfile):
"""
Write``PLTE`` and if necessary a ``tRNS`` chunk to.
This method should be called only from ``write_idat`` method
or chunk order will be ruined.
"""
# We must have true bitdepth within palette to use sBIT with palette
# if s... | python | {
"resource": ""
} |
q247889 | Writer.__write_text | train | def __write_text(self, outfile):
"""
Write text information into file
This method should be called only from ``write_idat`` method
or chunk order will be ruined.
"""
for k, v in self.text.items():
if not isinstance(v, bytes):
try:
... | python | {
"resource": ""
} |
q247890 | Writer.write_idat | train | def write_idat(self, outfile, idat_sequence):
"""
Write png with IDAT to file
`idat_sequence` should be iterable that produce IDAT chunks
compatible with `Writer` configuration.
"""
# http://www.w3.org/TR/PNG/#5PNG-file-signature
outfile.write(png_signature)
... | python | {
"resource": ""
} |
q247891 | Writer.comp_idat | train | def comp_idat(self, idat):
"""Generator that produce compressed IDAT chunks from IDAT data"""
# http://www.w3.org/TR/PNG/#11IDAT
if self.compression is not None:
compressor = zlib.compressobj(self.compression)
else:
compressor = zlib.compressobj()
for dat ... | python | {
"resource": ""
} |
q247892 | Writer.idat | train | def idat(self, rows, packed=False):
"""Generator that produce uncompressed IDAT data from rows"""
# http://www.w3.org/TR/PNG/#11IDAT
filt = Filter(self.bitdepth * self.planes,
self.interlace, self.height)
data = bytearray()
def byteextend(rowbytes):
... | python | {
"resource": ""
} |
q247893 | Writer.write_packed | train | def write_packed(self, outfile, rows):
"""
Write PNG file to `outfile`.
The pixel data comes from `rows` which should be in boxed row
packed format. Each row should be a sequence of packed bytes.
Technically, this method does work for interlaced images but it
is best a... | python | {
"resource": ""
} |
q247894 | MergedPlanes.newarray | train | def newarray(self, length, value=0):
"""Initialise empty row"""
if self.bitdepth > 8:
return array('H', [value] * | python | {
"resource": ""
} |
q247895 | MergedPlanes.rigthgen | train | def rigthgen(self, value=0):
"""Generate rows to fill right pixels in int mode"""
while True:
| python | {
"resource": ""
} |
q247896 | MergedPlanes.next | train | def next(self):
"""Generate merged row, consuming rows of original iterstors"""
left = next(self.seq_left)
if self.width is None:
self.width = len(left) / self.nplanes_left
if self.bitdepth is None:
# Detect bitdepth
if hasattr(left, 'itemsize'): # ar... | python | {
"resource": ""
} |
q247897 | Filter.filter_all | train | def filter_all(self, line):
"""Doing all filters for specified line
return filtered lines as list
For using with adaptive filters
"""
lines = [None] * 5
for filter_type in range(5): # range save more than 'optimised' order
res = | python | {
"resource": ""
} |
q247898 | Filter.do_filter | train | def do_filter(self, filter_type, line):
"""
Applying filter, caring about prev line, interlacing etc.
`filter_type` may be integer to apply basic filter or
adaptive strategy with dict
(`name` is reqired field, others may tune strategy)
"""
# Recall that filtering... | python | {
"resource": ""
} |
q247899 | _readable.read | train | def read(self, n):
"""Read `n` chars from buffer"""
r = self.buf[self.offset:self.offset + n]
if isinstance(r, array):
| python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.