本文整理汇总了Python中weakref.WeakKeyDictionary.setdefault方法的典型用法代码示例。如果您正苦于以下问题:Python WeakKeyDictionary.setdefault方法的具体用法?Python WeakKeyDictionary.setdefault怎么用?Python WeakKeyDictionary.setdefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weakref.WeakKeyDictionary
的用法示例。
在下文中一共展示了WeakKeyDictionary.setdefault方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GivenFunction
# 需要导入模块: from weakref import WeakKeyDictionary [as 别名]
# 或者: from weakref.WeakKeyDictionary import setdefault [as 别名]
class GivenFunction(IGivenFunction):
"""Adapter for a function :math:`f(x)` into an :class:`IGivenFunction`.
"""
def __init__(self, f):
"""Initialize the caches and store the function :math:`f`.
:param f: a valid argument to
:meth:`hedge.discretization.Discretization.interpolate_volume_function`.
"""
from weakref import WeakKeyDictionary
self.f = f
self.volume_cache = WeakKeyDictionary()
self.boundary_cache = WeakKeyDictionary()
def volume_interpolant(self, discr):
try:
return self.volume_cache[discr]
except KeyError:
result = discr.interpolate_volume_function(self.f,
dtype=discr.default_scalar_type)
self.volume_cache[discr] = result
return result
def boundary_interpolant(self, discr, tag):
try:
return self.boundary_cache[discr][tag]
except KeyError:
tag_cache = self.boundary_cache.setdefault(discr, {})
result = discr.interpolate_boundary_function(self.f, tag,
dtype=discr.default_scalar_type)
tag_cache[tag] = result
return result
示例2: DiffResultDescriptor
# 需要导入模块: from weakref import WeakKeyDictionary [as 别名]
# 或者: from weakref.WeakKeyDictionary import setdefault [as 别名]
class DiffResultDescriptor(object):
"""Descriptor for managing diff results."""
# @properties could be used instead, but there are so
# many result attributes, this will keep the code cleaner.
def __init__(self, diff_function):
self.diff_function = diff_function
# use weak references so instances can be
# garbage collected, rather than unnecessarily
# kept around due to this descriptor.
self.instances = WeakKeyDictionary()
def __get__(self, obj, objtype=None):
if obj is None:
return self
if self.instances.setdefault(obj, None) is None:
diff = getattr(obj, self.diff_function)
diff()
return self.instances[obj]
def __set__(self, obj, value):
self.instances[obj] = value
示例3: use
# 需要导入模块: from weakref import WeakKeyDictionary [as 别名]
# 或者: from weakref.WeakKeyDictionary import setdefault [as 别名]
class CriteriaDescriptor:
"""
Single item criteria descriptor.
Keyword Parameters:
name_regex The name of instance's regex setting attribute;
used as name_regex below. If unset,
regular expressions will never be used.
lookup_function The name of the SELinuxPolicy lookup function,
e.g. lookup_type or lookup_boolean.
default_value The default value of the criteria. The default
is None.
enum_class The class of enumeration which supports a
lookup class method.
Read-only instance attribute use (obj parameter):
policy The instance of SELinuxPolicy
name_regex This attribute is read to determine if
the criteria should be looked up or
compiled into a regex. If the attribute
does not exist, False is assumed.
"""
def __init__(self, name_regex=None, lookup_function=None, default_value=None, enum_class=None):
assert name_regex or lookup_function or enum_class, \
"A simple attribute should be used if there is no regex, lookup function, or enum."
assert not (lookup_function and enum_class), \
"Lookup functions and enum classes are mutually exclusive."
self.regex = name_regex
self.default_value = default_value
self.lookup_function = lookup_function
self.enum_class = enum_class
# use weak references so instances can be
# garbage collected, rather than unnecessarily
# kept around due to this descriptor.
self.instances = WeakKeyDictionary()
def __get__(self, obj, objtype=None):
if obj is None:
return self
return self.instances.setdefault(obj, self.default_value)
def __set__(self, obj, value):
if not value:
self.instances[obj] = None
elif self.regex and getattr(obj, self.regex, False):
self.instances[obj] = re.compile(value)
elif self.lookup_function:
lookup = getattr(obj.policy, self.lookup_function)
self.instances[obj] = lookup(value)
elif self.enum_class:
self.instances[obj] = self.enum_class.lookup(value)
else:
self.instances[obj] = value
示例4: RuletypeDescriptor
# 需要导入模块: from weakref import WeakKeyDictionary [as 别名]
# 或者: from weakref.WeakKeyDictionary import setdefault [as 别名]
class RuletypeDescriptor(object):
"""
Descriptor for a list of rule types.
Parameters:
validator The name of the SELinuxPolicy ruletype
validator function, e.g. validate_te_ruletype
default_value The default value of the criteria. The default
is None.
Read-only instance attribute use (obj parameter):
policy The instance of SELinuxPolicy
"""
def __init__(self, validator):
self.validator = validator
# use weak references so instances can be
# garbage collected, rather than unnecessarily
# kept around due to this descriptor.
self.instances = WeakKeyDictionary()
def __get__(self, obj, objtype=None):
if obj is None:
return self
return self.instances.setdefault(obj, None)
def __set__(self, obj, value):
if value:
validate = getattr(obj.policy, self.validator)
validate(value)
self.instances[obj] = value
else:
self.instances[obj] = None
示例5: CallbackProperty
# 需要导入模块: from weakref import WeakKeyDictionary [as 别名]
# 或者: from weakref.WeakKeyDictionary import setdefault [as 别名]
class CallbackProperty(object):
"""A property that callback functions can be added to.
When a callback property changes value, each callback function
is called with information about the state change. Otherwise,
callback properties behave just like normal instance variables.
CallbackProperties must be defined at the class level. Use
the helper function :func:`add_callback` to attach a callback to
a specific instance of a class with CallbackProperties
"""
def __init__(self, default=None, getter=None, setter=None, docstring=None):
"""
:param default: The initial value for the property
"""
self._default = default
self._callbacks = WeakKeyDictionary()
self._2arg_callbacks = WeakKeyDictionary()
self._disabled = WeakKeyDictionary()
self._values = WeakKeyDictionary()
if getter is None:
getter = self._default_getter
if setter is None:
setter = self._default_setter
self._getter = getter
self._setter = setter
if docstring is not None:
self.__doc__ = docstring
def _default_getter(self, instance, owner=None):
return self._values.get(instance, self._default)
def _default_setter(self, instance, value):
self._values.__setitem__(instance, value)
def __get__(self, instance, owner=None):
if instance is None:
return self
return self._getter(instance)
def __set__(self, instance, value):
try:
old = self.__get__(instance)
except AttributeError:
old = None
self._setter(instance, value)
new = self.__get__(instance)
if old != new:
self.notify(instance, old, new)
def setter(self, func):
"""
Method to use as a decorator, to mimic @property.setter
"""
self._setter = func
return self
def notify(self, instance, old, new):
"""Call all callback functions with the current value
:param instance: The instance to consider
:param old: The old value of the property
:param new: The new value of the property
Each callback will either be called using
callback(new) or callback(old, new) depending
on whether echo_old was True during add_callback
"""
if self._disabled.get(instance, False):
return
for cback in self._callbacks.get(instance, []):
cback(new)
for cback in self._2arg_callbacks.get(instance, []):
cback(old, new)
def disable(self, instance):
"""Disable callbacks for a specific instance"""
self._disabled[instance] = True
def enable(self, instance):
"""Enable previously-disabled callbacks for a specific instance"""
self._disabled[instance] = False
def add_callback(self, instance, func, echo_old=False):
"""Add a callback to a specific instance that manages this property
:param instance: Instance to bind the callback to
:param func: Callback function
:param echo_old: If true, the callback function will be invoked
with both the old and new values of the property, as func(old, new)
If False (the default), will be invoked as func(new)
"""
if echo_old:
self._2arg_callbacks.setdefault(instance, []).append(func)
#.........这里部分代码省略.........
示例6: IdleComponent
# 需要导入模块: from weakref import WeakKeyDictionary [as 别名]
# 或者: from weakref.WeakKeyDictionary import setdefault [as 别名]
class IdleComponent(Component, HasTunableFactory, component_name=types.IDLE_COMPONENT):
__qualname__ = 'IdleComponent'
FACTORY_TUNABLES = {'idle_animation_map': TunableMapping(description='\n The animations that the attached object can play.\n ', key_type=TunableReference(manager=services.get_instance_manager(sims4.resources.Types.OBJECT_STATE), class_restrictions='ObjectStateValue'), value_type=TunableReference(description='\n The animation to play when the object is in the specified state.\n If you want the object to stop playing idles, you must tune an\n animation element corresponding to an ASM state that requests a\n stop on the object.\n ', manager=services.get_instance_manager(sims4.resources.Types.ANIMATION), class_restrictions='ObjectAnimationElement'))}
def __init__(self, owner, idle_animation_map):
super().__init__(owner)
self._idle_animation_map = idle_animation_map
self._asm_registry = WeakKeyDictionary()
self._animation_context = AnimationContext()
self._animation_context.add_ref(self)
self._idle_animation_element = None
self._current_idle_state_value = None
def get_asm(self, asm_key, actor_name, setup_asm_func=None, use_cache=True, cache_key=DEFAULT, **kwargs):
if use_cache:
asm_dict = self._asm_registry.setdefault(self._animation_context, {})
asm = None
if asm_key in asm_dict:
asm = asm_dict[asm_key]
if asm.current_state == 'exit':
asm = None
if asm is None:
asm = animation.asm.Asm(asm_key, context=self._animation_context)
asm_dict[asm_key] = asm
else:
asm = animation.asm.Asm(asm_key, context=self._animation_context)
asm.set_actor(actor_name, self.owner)
if not (setup_asm_func is not None and setup_asm_func(asm)):
return
return asm
def _refresh_active_idle(self):
if self._current_idle_state_value is not None and self._idle_animation_element is not None:
self._trigger_idle_animation(self._current_idle_state_value.state, self._current_idle_state_value)
def on_state_changed(self, state, old_value, new_value):
if self._trigger_idle_animation(state, new_value) or new_value.anim_overrides is not None and old_value != new_value:
self._refresh_active_idle()
def _trigger_idle_animation(self, state, new_value):
if new_value in self._idle_animation_map:
new_animation = self._idle_animation_map[new_value]
self._hard_stop_animation_element()
self._current_idle_state_value = new_value
if new_animation is not None:
animation_element = new_animation(self.owner)
self._idle_animation_element = build_element((animation_element, flush_all_animations))
services.time_service().sim_timeline.schedule(self._idle_animation_element)
return True
return False
def _hard_stop_animation_element(self):
if self._idle_animation_element is not None:
self._idle_animation_element.trigger_hard_stop()
self._idle_animation_element = None
self._current_idle_state_value = None
def on_remove(self, *_, **__):
if self._animation_context is not None:
self._animation_context.release_ref(self)
self._animation_context = None
self._hard_stop_animation_element()
示例7: newSADatum
# 需要导入模块: from weakref import WeakKeyDictionary [as 别名]
# 或者: from weakref.WeakKeyDictionary import setdefault [as 别名]
def newSADatum(metadata):
table_to_managed_class = WeakKeyDictionary()
for class_, manager_getter in instrumentation_registry._manager_finders.iteritems():
table_to_managed_class.setdefault(manager_getter(class_).mapper.local_table, []).append(class_)
def default_value(column_def):
if column_def.default is None:
return None
if not column_def.default.is_scalar:
warn("non-scalar default value is not supported")
return None
return column_def.default.arg
mixin_class_registry = WeakKeyDictionary()
def clone_mapper(mapper_, class_):
def clone_property(prop):
if isinstance(prop, RelationshipProperty):
if is_callable(prop.argument):
argument_ = lambda: lookup_mixin_class(prop.argument())
else:
argument_ = lookup_mixin_class(prop.argument)
return relationship(
argument_,
secondary=prop.secondary,
primaryjoin=prop.primaryjoin,
secondaryjoin=prop.secondaryjoin,
foreign_keys=prop._user_defined_foreign_keys,
uselist=prop.uselist,
order_by=prop.order_by,
backref=prop.backref,
back_populates=prop.back_populates,
post_update=prop.post_update,
cascade=",".join(prop.cascade),
extension=prop.extension,
viewonly=prop.viewonly,
lazy=prop.lazy,
collection_class=prop.collection_class,
passive_deletes=prop.passive_deletes,
passive_updates=prop.passive_updates,
remote_side=prop.remote_side,
enable_typechecks=prop.enable_typechecks,
join_depth=prop.join_depth,
comparator_factory=prop.comparator_factory,
single_parent=prop.single_parent,
innerjoin=prop.innerjoin,
doc=prop.doc,
active_history=prop.active_history,
cascade_backrefs=prop.cascade_backrefs,
load_on_pending=prop.load_on_pending,
strategy_class=prop.strategy_class,
query_class=prop.query_class
)
else:
return prop
return mapper(
class_=class_,
local_table=mapper_.local_table,
properties=dict((prop.key, clone_property(prop)) for prop in mapper_.iterate_properties),
primary_key=mapper_.primary_key,
non_primary=False,
inherits=(mapper_.inherits and lookup_mixin_class(mapper_.inherits.class_)),
inherit_condition=mapper_.inherit_condition,
inherit_foreign_keys=mapper_.inherit_foreign_keys,
order_by=mapper_.order_by,
always_refresh=mapper_.always_refresh,
version_id_col=mapper_.version_id_col,
version_id_generator=mapper_.version_id_generator,
polymorphic_on=mapper_.polymorphic_on,
polymorphic_identity=mapper_.polymorphic_identity,
concrete=mapper_.concrete,
with_polymorphic=mapper_.with_polymorphic,
allow_partial_pks=mapper_.allow_partial_pks,
batch=mapper_.batch,
column_prefix=mapper_.column_prefix,
include_properties=mapper_.include_properties,
exclude_properties=mapper_.exclude_properties,
passive_updates=mapper_.passive_updates,
eager_defaults=mapper_.eager_defaults
)
def lookup_mixin_class(managed_class):
class_name = "SADatum#%s" % managed_class.__name__
retval = mixin_class_registry.get(managed_class)
if retval is None:
mapper = manager_of_class(managed_class).mapper
dict_ = dict(pair for pair in managed_class.__dict__.items()
if not isinstance(pair[1], InstrumentedAttribute) and pair[0] != '__init__' and not pair[0].startswith('_sa_'))
dict_['_tableau_managed_class'] = managed_class
if mapper.inherits:
super_ = lookup_mixin_class(mapper.inherits.class_)
else:
super_ = SADatum
retval = type(class_name, (super_, ), dict_)
retval.__mapper__ = clone_mapper(mapper, retval)
mixin_class_registry[managed_class] = retval
return retval
def managed_class_of_table(table):
#.........这里部分代码省略.........
示例8: CallbackProperty
# 需要导入模块: from weakref import WeakKeyDictionary [as 别名]
# 或者: from weakref.WeakKeyDictionary import setdefault [as 别名]
#.........这里部分代码省略.........
def _get_full_info(self, instance):
# Some callback subclasses may contain additional info in addition
# to the main value, and we need to use this full information when
# comparing old and new 'values', so this method is used in that
# case. The result should be a tuple where the first item is the
# actual primary value of the property and the second item is any
# additional data to use in the comparison.
# Note that we need to make sure we convert any list here to a tuple
# to make sure the value is immutable, otherwise comparisons of
# old != new will not show any difference (since the list can still)
# be modified in-place
value = self.__get__(instance)
if isinstance(value, list):
value = tuple(value)
return value, None
def notify(self, instance, old, new):
"""
Call all callback functions with the current value
Each callback will either be called using
callback(new) or callback(old, new) depending
on whether ``echo_old`` was set to `True` when calling
:func:`~echo.add_callback`
Parameters
----------
instance
The instance to consider
old
The old value of the property
new
The new value of the property
"""
if self._disabled.get(instance, False):
return
for cback in self._callbacks.get(instance, []):
cback(new)
for cback in self._2arg_callbacks.get(instance, []):
cback(old, new)
def disable(self, instance):
"""
Disable callbacks for a specific instance
"""
self._disabled[instance] = True
def enable(self, instance):
"""
Enable previously-disabled callbacks for a specific instance
"""
self._disabled[instance] = False
def add_callback(self, instance, func, echo_old=False, priority=0):
"""
Add a callback to a specific instance that manages this property
Parameters
----------
instance
The instance to add the callback to
func : func
The callback function to add
echo_old : bool, optional
If `True`, the callback function will be invoked with both the old
and new values of the property, as ``func(old, new)``. If `False`
(the default), will be invoked as ``func(new)``
priority : int, optional
This can optionally be used to force a certain order of execution of
callbacks (larger values indicate a higher priority).
"""
if echo_old:
self._2arg_callbacks.setdefault(instance, CallbackContainer()).append(func, priority=priority)
else:
self._callbacks.setdefault(instance, CallbackContainer()).append(func, priority=priority)
def remove_callback(self, instance, func):
"""
Remove a previously-added callback
Parameters
----------
instance
The instance to detach the callback from
func : func
The callback function to remove
"""
for cb in [self._callbacks, self._2arg_callbacks]:
if instance not in cb:
continue
if func in cb[instance]:
cb[instance].remove(func)
return
else:
raise ValueError("Callback function not found: %s" % func)
示例9: index_walker
# 需要导入模块: from weakref import WeakKeyDictionary [as 别名]
# 或者: from weakref.WeakKeyDictionary import setdefault [as 别名]
class index_walker(ListWalker, MetaMixin):
#__slots__ = ('focus', '_tids', '_query', 'container', '_wstorage', '_rows', '_urwid_signals')
signals = ['modified', 'keypress']
context = 'index_mode'
def __hash__(self): return id(self)
def __init__(self, query):
self._tids = []
#self._wstorage = {}
self._wstorage = WeakKeyDictionary()
self._rows = 20
self.container = thread_container()
self._query = query
self.focus = 0
self.more_threads()
def _modified(self):
if self.focus >= len(self.container):
self.focus = max(0, len(self.container)-1)
ListWalker._modified(self)
#emit_signal(self, 'modified')
def get_focus(self):
if len(self.container) == 0: return None, None
w = self._get_widget(self.container[self.focus])
return w, self.focus
def set_focus(self, position):
assert type(position) is int
self.focus = position
self._modified()
def get_next(self, start_from):
pos = start_from + 1
if len(self.container) <= pos:
if len(self.container) != len(self._tids):
self._more_threads()
#thread = self.more_threads()
#thread.join()
elif self.chk_new():
self._more_threads()
#thread = self.more_threads()
#thread.join()
else: return None, None
return None, None
w = self._get_widget(self.container[pos])
return w, pos
def get_prev(self, start_from):
pos = start_from - 1
if pos < 0: return None, None
w = self._get_widget(self.container[pos])
return w, pos
def _get_widget(self, conv):
w = self._wstorage.setdefault(conv, conv_widget())
if not hasattr(w, '_conv'):
w._init(conv)
connect_signal(w, 'modified', self._modified)
connect_signal(w, 'keypress', self.keypress)
return w
def _keypress(self, key):
if key == "r":
emit_signal(eband, 'log', str(len(self.container)))
elif key == "e":
self._more_threads()
def more_threads(self):
thread = Thread(target=self._more_threads)
thread.start()
return thread
def _more_threads(self):
emit_signal(eband, 'log', 'running more_threads')
cur = len(self.container)
emit_signal(eband, 'log', 'len container at start: %s' % str(cur))
sconn = xappy.SearchConnection(srchidx)
self._update_tids(sconn)
to_get = filter(lambda x: x not in self.container._map, self._tids[:cur])
to_get = filterNone(set(to_get))
#emit_signal(eband, 'log', str(to_get))
to_get.extend(self._tids[cur:(cur+self._rows-len(to_get))])
#emit_signal(eband, 'log', str(to_get))
self._add_more_threads(sconn, to_get)
sconn.close()
def do_all_threads(self, size, key):
self._all_threads()
def _all_threads(self):
sconn = xappy.SearchConnection(srchidx)
self._update_tids(sconn)
self._add_more_threads(sconn, self._tids)
#.........这里部分代码省略.........
示例10: Manager
# 需要导入模块: from weakref import WeakKeyDictionary [as 别名]
# 或者: from weakref.WeakKeyDictionary import setdefault [as 别名]
class Manager(object):
"""
All communication between the L{Universe}, L{UserInterface}, and L{Window}
happens here. It is essential for preserving an X{MVC} paradigm.
L{Listener}s register themselves with the Manager, and then they can send
events to the Manager. When the manager gets an event, it is interpreted
and passed along to any L{Listener} that is X{listening} for that event.
"""
def __init__(self,eventTimer,debugger):
"""
Set up a manager with an empty L{Listener} L{WeakKeyDictionary}, an
empty eventQueue, and a timer used for timestamps.
@param listeners:
@param eventTypesToListeners:
@param eventQueue: A list of all events that come in for processing.
@param eventTimer: Used for timestamps.
@param debugger: Listens for all events and records events if it is
activated.
@type debugger: L{Debugger}
"""
from weakref import WeakKeyDictionary
self.listeners = WeakKeyDictionary()
self.eventTypesToListeners = WeakKeyDictionary()
self.eventQueue = []
self.eventTimer = eventTimer
self.debugger = debugger
def registerListener( self, listener ):
"""
Registers a listener with the event manager to be nofitied
when the events in the attribute eventTypes of the listener
are received.
"""
for evType in listener.eventTypes:
self.eventTypesToListeners.setdefault(evType,[]).append(listener)
self.listeners[ listener ] = None
def unregisterListener( self, listener ):
"""
Removes a listener from the dictionary of listeners.
"""
# FIXME---! eventTypesToListeners!
if listener in self.listeners:
del self.listeners[ listener ]
def post( self, event ):
"""
Sends an event to the listeners which should be notified
depending on the type of event. The manager will also
set the time stamp of the event.
"""
event.timeFired = self.eventTimer.getTime()
if self.debugger.SYMBOLS_ENABLED:
self.debugger.logMsg(event)
##SOME LISTENERS SHOULD START THEIR OWN THREADS (eventually)
for listener in self.eventTypesToListeners.get(type(event),[]):
listener.notify(event)
示例11: setdefault
# 需要导入模块: from weakref import WeakKeyDictionary [as 别名]
# 或者: from weakref.WeakKeyDictionary import setdefault [as 别名]
def setdefault(self, key, default=None):
#og_v = self.data[ref(key)]
v = WeakKeyDictionary.setdefault(key, default)
#if v is not og_v:
self.doCallbacks('setdefault', key, default)
示例12: ContentTool
# 需要导入模块: from weakref import WeakKeyDictionary [as 别名]
# 或者: from weakref.WeakKeyDictionary import setdefault [as 别名]
class ContentTool(object):
def __init__(self, hooks=[]):
super(ContentTool, self).__init__()
self.hooks = hooks
self.iomap = WeakKeyDictionary()
def pipe(self, chunks, meta_data):
return self._pipe_chunks(chunks, meta_data), meta_data
def _pipe_chunks(self, chunks, meta_data):
self.iomap = WeakKeyDictionary()
for old_chunk in chunks:
#old_repr = repr(old_chunk)
for hook in self.hooks:
hook.before_process_chunk(old_chunk)
result = self.process_chunk(old_chunk, meta_data)
self.iomap.setdefault(old_chunk, WeakList())
if isinstance(result, list):
#for new_chunk in result:
# self._verify_not_mutated(old_chunk, old_repr, new_chunk)
for hook in self.hooks:
hook.after_chunk_removed(old_chunk)
for new_chunk in result:
self.iomap[old_chunk].append(new_chunk)
for hook in self.hooks:
hook.after_chunk_added(new_chunk)
yield new_chunk
elif isinstance(result, ast.Chunk):
#self._verify_not_mutated(old_chunk, old_repr, result)
if result is old_chunk:
self.iomap[old_chunk].append(old_chunk)
for hook in self.hooks:
hook.after_chunk_unmodified(result)
else:
self.iomap[old_chunk].append(result)
for hook in self.hooks:
hook.after_chunk_removed(old_chunk)
hook.after_chunk_added(result)
yield result
elif result is None:
for hook in self.hooks:
hook.after_chunk_removed(old_chunk)
else:
# TODO: contract error: bad return value
raise RuntimeError()
#def _verify_not_mutated(self, old_chunk, old_repr, new_chunk):
# if new_chunk is old_chunk and repr(new_chunk) != old_repr:
# # TODO: contract error: chunks are immutable
# raise RuntimeError()
# XXX:
# - this computation may not depend on what chunks appeared earlier,
# only on the current chunk and the meta_data
def process_chunk(self, chunk, meta_data):
return chunk