repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
tcalmant/ipopo
pelix/ipopo/decorators.py
get_factory_context
def get_factory_context(cls): # type: (type) -> FactoryContext """ Retrieves the factory context object associated to a factory. Creates it if needed :param cls: The factory class :return: The factory class context """ context = getattr(cls, constants.IPOPO_FACTORY_CONTEXT, None) i...
python
def get_factory_context(cls): # type: (type) -> FactoryContext """ Retrieves the factory context object associated to a factory. Creates it if needed :param cls: The factory class :return: The factory class context """ context = getattr(cls, constants.IPOPO_FACTORY_CONTEXT, None) i...
[ "def", "get_factory_context", "(", "cls", ")", ":", "# type: (type) -> FactoryContext", "context", "=", "getattr", "(", "cls", ",", "constants", ".", "IPOPO_FACTORY_CONTEXT", ",", "None", ")", "if", "context", "is", "None", ":", "# Class not yet manipulated", "conte...
Retrieves the factory context object associated to a factory. Creates it if needed :param cls: The factory class :return: The factory class context
[ "Retrieves", "the", "factory", "context", "object", "associated", "to", "a", "factory", ".", "Creates", "it", "if", "needed" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/decorators.py#L96-L121
tcalmant/ipopo
pelix/ipopo/decorators.py
get_method_description
def get_method_description(method): # type: (Callable) -> str """ Retrieves a description of the given method. If possible, the description contains the source file name and line. :param method: A method :return: A description of the method (at least its name) :raise AttributeError: Given o...
python
def get_method_description(method): # type: (Callable) -> str """ Retrieves a description of the given method. If possible, the description contains the source file name and line. :param method: A method :return: A description of the method (at least its name) :raise AttributeError: Given o...
[ "def", "get_method_description", "(", "method", ")", ":", "# type: (Callable) -> str", "try", ":", "try", ":", "line_no", "=", "inspect", ".", "getsourcelines", "(", "method", ")", "[", "1", "]", "except", "IOError", ":", "# Error reading the source file", "line_n...
Retrieves a description of the given method. If possible, the description contains the source file name and line. :param method: A method :return: A description of the method (at least its name) :raise AttributeError: Given object has no __name__ attribute
[ "Retrieves", "a", "description", "of", "the", "given", "method", ".", "If", "possible", "the", "description", "contains", "the", "source", "file", "name", "and", "line", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/decorators.py#L124-L146
tcalmant/ipopo
pelix/ipopo/decorators.py
validate_method_arity
def validate_method_arity(method, *needed_args): # type: (Callable, *str) -> None """ Tests if the decorated method has a sufficient number of parameters. :param method: The method to be tested :param needed_args: The name (for description only) of the needed arguments, with...
python
def validate_method_arity(method, *needed_args): # type: (Callable, *str) -> None """ Tests if the decorated method has a sufficient number of parameters. :param method: The method to be tested :param needed_args: The name (for description only) of the needed arguments, with...
[ "def", "validate_method_arity", "(", "method", ",", "*", "needed_args", ")", ":", "# type: (Callable, *str) -> None", "nb_needed_args", "=", "len", "(", "needed_args", ")", "# Test the number of parameters", "arg_spec", "=", "get_method_arguments", "(", "method", ")", "...
Tests if the decorated method has a sufficient number of parameters. :param method: The method to be tested :param needed_args: The name (for description only) of the needed arguments, without "self". :return: Nothing :raise TypeError: Invalid number of parameter
[ "Tests", "if", "the", "decorated", "method", "has", "a", "sufficient", "number", "of", "parameters", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/decorators.py#L149-L196
tcalmant/ipopo
pelix/ipopo/decorators.py
_ipopo_setup_callback
def _ipopo_setup_callback(cls, context): # type: (type, FactoryContext) -> None """ Sets up the class _callback dictionary :param cls: The class to handle :param context: The factory class context """ assert inspect.isclass(cls) assert isinstance(context, FactoryContext) if context...
python
def _ipopo_setup_callback(cls, context): # type: (type, FactoryContext) -> None """ Sets up the class _callback dictionary :param cls: The class to handle :param context: The factory class context """ assert inspect.isclass(cls) assert isinstance(context, FactoryContext) if context...
[ "def", "_ipopo_setup_callback", "(", "cls", ",", "context", ")", ":", "# type: (type, FactoryContext) -> None", "assert", "inspect", ".", "isclass", "(", "cls", ")", "assert", "isinstance", "(", "context", ",", "FactoryContext", ")", "if", "context", ".", "callbac...
Sets up the class _callback dictionary :param cls: The class to handle :param context: The factory class context
[ "Sets", "up", "the", "class", "_callback", "dictionary" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/decorators.py#L202-L257
tcalmant/ipopo
pelix/ipopo/decorators.py
_ipopo_setup_field_callback
def _ipopo_setup_field_callback(cls, context): # type: (type, FactoryContext) -> None """ Sets up the class _field_callback dictionary :param cls: The class to handle :param context: The factory class context """ assert inspect.isclass(cls) assert isinstance(context, FactoryContext) ...
python
def _ipopo_setup_field_callback(cls, context): # type: (type, FactoryContext) -> None """ Sets up the class _field_callback dictionary :param cls: The class to handle :param context: The factory class context """ assert inspect.isclass(cls) assert isinstance(context, FactoryContext) ...
[ "def", "_ipopo_setup_field_callback", "(", "cls", ",", "context", ")", ":", "# type: (type, FactoryContext) -> None", "assert", "inspect", ".", "isclass", "(", "cls", ")", "assert", "isinstance", "(", "context", ",", "FactoryContext", ")", "if", "context", ".", "f...
Sets up the class _field_callback dictionary :param cls: The class to handle :param context: The factory class context
[ "Sets", "up", "the", "class", "_field_callback", "dictionary" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/decorators.py#L260-L317
tcalmant/ipopo
pelix/ipopo/decorators.py
_append_object_entry
def _append_object_entry(obj, list_name, entry): # type: (Any, str, Any) -> None """ Appends the given entry in the given object list. Creates the list field if needed. :param obj: The object that contains the list :param list_name: The name of the list member in *obj* :param entry: The ent...
python
def _append_object_entry(obj, list_name, entry): # type: (Any, str, Any) -> None """ Appends the given entry in the given object list. Creates the list field if needed. :param obj: The object that contains the list :param list_name: The name of the list member in *obj* :param entry: The ent...
[ "def", "_append_object_entry", "(", "obj", ",", "list_name", ",", "entry", ")", ":", "# type: (Any, str, Any) -> None", "# Get the list", "obj_list", "=", "getattr", "(", "obj", ",", "list_name", ",", "None", ")", "if", "obj_list", "is", "None", ":", "# We'll ha...
Appends the given entry in the given object list. Creates the list field if needed. :param obj: The object that contains the list :param list_name: The name of the list member in *obj* :param entry: The entry to be added to the list :raise ValueError: Invalid attribute content
[ "Appends", "the", "given", "entry", "in", "the", "given", "object", "list", ".", "Creates", "the", "list", "field", "if", "needed", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/decorators.py#L335-L357
tcalmant/ipopo
pelix/ipopo/decorators.py
_ipopo_class_field_property
def _ipopo_class_field_property(name, value, methods_prefix): # type: (str, Any, str) -> property """ Sets up an iPOPO field property, using Python property() capabilities :param name: The property name :param value: The property default value :param methods_prefix: The common prefix of the get...
python
def _ipopo_class_field_property(name, value, methods_prefix): # type: (str, Any, str) -> property """ Sets up an iPOPO field property, using Python property() capabilities :param name: The property name :param value: The property default value :param methods_prefix: The common prefix of the get...
[ "def", "_ipopo_class_field_property", "(", "name", ",", "value", ",", "methods_prefix", ")", ":", "# type: (str, Any, str) -> property", "# The property lock", "lock", "=", "threading", ".", "RLock", "(", ")", "# Prepare the methods names", "getter_name", "=", "\"{0}{1}\"...
Sets up an iPOPO field property, using Python property() capabilities :param name: The property name :param value: The property default value :param methods_prefix: The common prefix of the getter and setter injected methods :return: A generated Python property()
[ "Sets", "up", "an", "iPOPO", "field", "property", "using", "Python", "property", "()", "capabilities" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/decorators.py#L376-L424
tcalmant/ipopo
pelix/ipopo/decorators.py
_get_specifications
def _get_specifications(specifications): """ Computes the list of strings corresponding to the given specifications :param specifications: A string, a class or a list of specifications :return: A list of strings :raise ValueError: Invalid specification found """ if not specifications or spe...
python
def _get_specifications(specifications): """ Computes the list of strings corresponding to the given specifications :param specifications: A string, a class or a list of specifications :return: A list of strings :raise ValueError: Invalid specification found """ if not specifications or spe...
[ "def", "_get_specifications", "(", "specifications", ")", ":", "if", "not", "specifications", "or", "specifications", "is", "object", ":", "raise", "ValueError", "(", "\"No specifications given\"", ")", "elif", "inspect", ".", "isclass", "(", "specifications", ")", ...
Computes the list of strings corresponding to the given specifications :param specifications: A string, a class or a list of specifications :return: A list of strings :raise ValueError: Invalid specification found
[ "Computes", "the", "list", "of", "strings", "corresponding", "to", "the", "given", "specifications" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/decorators.py#L839-L885
tcalmant/ipopo
pelix/ipopo/decorators.py
Bind
def Bind(method): # pylint: disable=C0103 """ The ``@Bind`` callback decorator is called when a component is bound to a dependency. The decorated method must accept the injected service object and its :class:`~pelix.framework.ServiceReference` as arguments:: @Bind def bind_method...
python
def Bind(method): # pylint: disable=C0103 """ The ``@Bind`` callback decorator is called when a component is bound to a dependency. The decorated method must accept the injected service object and its :class:`~pelix.framework.ServiceReference` as arguments:: @Bind def bind_method...
[ "def", "Bind", "(", "method", ")", ":", "# pylint: disable=C0103", "if", "not", "inspect", ".", "isroutine", "(", "method", ")", ":", "raise", "TypeError", "(", "\"@Bind can only be applied on functions\"", ")", "# Tests the number of parameters", "validate_method_arity",...
The ``@Bind`` callback decorator is called when a component is bound to a dependency. The decorated method must accept the injected service object and its :class:`~pelix.framework.ServiceReference` as arguments:: @Bind def bind_method(self, service, service_reference): ''' ...
[ "The", "@Bind", "callback", "decorator", "is", "called", "when", "a", "component", "is", "bound", "to", "a", "dependency", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/decorators.py#L1674-L1710
tcalmant/ipopo
pelix/ipopo/decorators.py
Update
def Update(method): # pylint: disable=C0103 """ The ``@Update`` callback decorator is called when the properties of an injected service have been modified. The decorated method must accept the injected service object and its :class:`~pelix.framework.ServiceReference` and the previous properties...
python
def Update(method): # pylint: disable=C0103 """ The ``@Update`` callback decorator is called when the properties of an injected service have been modified. The decorated method must accept the injected service object and its :class:`~pelix.framework.ServiceReference` and the previous properties...
[ "def", "Update", "(", "method", ")", ":", "# pylint: disable=C0103", "if", "not", "isinstance", "(", "method", ",", "types", ".", "FunctionType", ")", ":", "raise", "TypeError", "(", "\"@Update can only be applied on functions\"", ")", "# Tests the number of parameters"...
The ``@Update`` callback decorator is called when the properties of an injected service have been modified. The decorated method must accept the injected service object and its :class:`~pelix.framework.ServiceReference` and the previous properties as arguments:: @Update def update_method...
[ "The", "@Update", "callback", "decorator", "is", "called", "when", "the", "properties", "of", "an", "injected", "service", "have", "been", "modified", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/decorators.py#L1713-L1750
tcalmant/ipopo
pelix/ipopo/decorators.py
Unbind
def Unbind(method): # pylint: disable=C0103 """ The ``@Unbind`` callback decorator is called when a component dependency is unbound. The decorated method must accept the injected service object and its :class:`~pelix.framework.ServiceReference` as arguments:: @Unbind def unbind_m...
python
def Unbind(method): # pylint: disable=C0103 """ The ``@Unbind`` callback decorator is called when a component dependency is unbound. The decorated method must accept the injected service object and its :class:`~pelix.framework.ServiceReference` as arguments:: @Unbind def unbind_m...
[ "def", "Unbind", "(", "method", ")", ":", "# pylint: disable=C0103", "if", "not", "isinstance", "(", "method", ",", "types", ".", "FunctionType", ")", ":", "raise", "TypeError", "(", "\"@Unbind can only be applied on functions\"", ")", "# Tests the number of parameters"...
The ``@Unbind`` callback decorator is called when a component dependency is unbound. The decorated method must accept the injected service object and its :class:`~pelix.framework.ServiceReference` as arguments:: @Unbind def unbind_method(self, service, service_reference): ''' ...
[ "The", "@Unbind", "callback", "decorator", "is", "called", "when", "a", "component", "dependency", "is", "unbound", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/decorators.py#L1753-L1789
tcalmant/ipopo
pelix/ipopo/decorators.py
PostRegistration
def PostRegistration(method): # pylint: disable=C0103 """ The service post-registration callback decorator is called after a service of the component has been registered to the framework. The decorated method must accept the :class:`~pelix.framework.ServiceReference` of the registered servi...
python
def PostRegistration(method): # pylint: disable=C0103 """ The service post-registration callback decorator is called after a service of the component has been registered to the framework. The decorated method must accept the :class:`~pelix.framework.ServiceReference` of the registered servi...
[ "def", "PostRegistration", "(", "method", ")", ":", "# pylint: disable=C0103", "if", "not", "isinstance", "(", "method", ",", "types", ".", "FunctionType", ")", ":", "raise", "TypeError", "(", "\"@PostRegistration can only be applied on functions\"", ")", "# Tests the n...
The service post-registration callback decorator is called after a service of the component has been registered to the framework. The decorated method must accept the :class:`~pelix.framework.ServiceReference` of the registered service as argument:: @PostRegistration def callback_method(...
[ "The", "service", "post", "-", "registration", "callback", "decorator", "is", "called", "after", "a", "service", "of", "the", "component", "has", "been", "registered", "to", "the", "framework", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/decorators.py#L1994-L2024
tcalmant/ipopo
pelix/ipopo/decorators.py
PostUnregistration
def PostUnregistration(method): # pylint: disable=C0103 """ The service post-unregistration callback decorator is called after a service of the component has been unregistered from the framework. The decorated method must accept the :class:`~pelix.framework.ServiceReference` of the registered ...
python
def PostUnregistration(method): # pylint: disable=C0103 """ The service post-unregistration callback decorator is called after a service of the component has been unregistered from the framework. The decorated method must accept the :class:`~pelix.framework.ServiceReference` of the registered ...
[ "def", "PostUnregistration", "(", "method", ")", ":", "# pylint: disable=C0103", "if", "not", "isinstance", "(", "method", ",", "types", ".", "FunctionType", ")", ":", "raise", "TypeError", "(", "\"@PostUnregistration can only be applied on functions\"", ")", "# Tests t...
The service post-unregistration callback decorator is called after a service of the component has been unregistered from the framework. The decorated method must accept the :class:`~pelix.framework.ServiceReference` of the registered service as argument:: @PostUnregistration def callback...
[ "The", "service", "post", "-", "unregistration", "callback", "decorator", "is", "called", "after", "a", "service", "of", "the", "component", "has", "been", "unregistered", "from", "the", "framework", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/decorators.py#L2027-L2057
tcalmant/ipopo
pelix/shell/core.py
_ShellUtils.bundlestate_to_str
def bundlestate_to_str(state): """ Converts a bundle state integer to a string """ states = { pelix.Bundle.INSTALLED: "INSTALLED", pelix.Bundle.ACTIVE: "ACTIVE", pelix.Bundle.RESOLVED: "RESOLVED", pelix.Bundle.STARTING: "STARTING", ...
python
def bundlestate_to_str(state): """ Converts a bundle state integer to a string """ states = { pelix.Bundle.INSTALLED: "INSTALLED", pelix.Bundle.ACTIVE: "ACTIVE", pelix.Bundle.RESOLVED: "RESOLVED", pelix.Bundle.STARTING: "STARTING", ...
[ "def", "bundlestate_to_str", "(", "state", ")", ":", "states", "=", "{", "pelix", ".", "Bundle", ".", "INSTALLED", ":", "\"INSTALLED\"", ",", "pelix", ".", "Bundle", ".", "ACTIVE", ":", "\"ACTIVE\"", ",", "pelix", ".", "Bundle", ".", "RESOLVED", ":", "\"...
Converts a bundle state integer to a string
[ "Converts", "a", "bundle", "state", "integer", "to", "a", "string" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/core.py#L80-L93
tcalmant/ipopo
pelix/shell/core.py
_ShellUtils.make_table
def make_table(headers, lines, prefix=None): """ Generates an ASCII table according to the given headers and lines :param headers: List of table headers (N-tuple) :param lines: List of table lines (N-tuples) :param prefix: Optional prefix for each line :return: The ASCII...
python
def make_table(headers, lines, prefix=None): """ Generates an ASCII table according to the given headers and lines :param headers: List of table headers (N-tuple) :param lines: List of table lines (N-tuples) :param prefix: Optional prefix for each line :return: The ASCII...
[ "def", "make_table", "(", "headers", ",", "lines", ",", "prefix", "=", "None", ")", ":", "# Normalize the prefix", "prefix", "=", "str", "(", "prefix", "or", "\"\"", ")", "# Maximum lengths", "lengths", "=", "[", "len", "(", "title", ")", "for", "title", ...
Generates an ASCII table according to the given headers and lines :param headers: List of table headers (N-tuple) :param lines: List of table lines (N-tuples) :param prefix: Optional prefix for each line :return: The ASCII representation of the table :raise ValueError: Different...
[ "Generates", "an", "ASCII", "table", "according", "to", "the", "given", "headers", "and", "lines" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/core.py#L96-L180
tcalmant/ipopo
pelix/shell/core.py
_ShellService.bind_handler
def bind_handler(self, svc_ref): """ Called if a command service has been found. Registers the methods of this service. :param svc_ref: A reference to the found service :return: True if the commands have been registered """ if svc_ref in self._bound_references: ...
python
def bind_handler(self, svc_ref): """ Called if a command service has been found. Registers the methods of this service. :param svc_ref: A reference to the found service :return: True if the commands have been registered """ if svc_ref in self._bound_references: ...
[ "def", "bind_handler", "(", "self", ",", "svc_ref", ")", ":", "if", "svc_ref", "in", "self", ".", "_bound_references", ":", "# Already bound service", "return", "False", "# Get the service", "handler", "=", "self", ".", "_context", ".", "get_service", "(", "svc_...
Called if a command service has been found. Registers the methods of this service. :param svc_ref: A reference to the found service :return: True if the commands have been registered
[ "Called", "if", "a", "command", "service", "has", "been", "found", ".", "Registers", "the", "methods", "of", "this", "service", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/core.py#L239-L266
tcalmant/ipopo
pelix/shell/core.py
_ShellService.unbind_handler
def unbind_handler(self, svc_ref): """ Called if a command service is gone. Unregisters its commands. :param svc_ref: A reference to the unbound service :return: True if the commands have been unregistered """ if svc_ref not in self._bound_references: ...
python
def unbind_handler(self, svc_ref): """ Called if a command service is gone. Unregisters its commands. :param svc_ref: A reference to the unbound service :return: True if the commands have been unregistered """ if svc_ref not in self._bound_references: ...
[ "def", "unbind_handler", "(", "self", ",", "svc_ref", ")", ":", "if", "svc_ref", "not", "in", "self", ".", "_bound_references", ":", "# Unknown reference", "return", "False", "# Unregister its commands", "namespace", ",", "commands", "=", "self", ".", "_reference_...
Called if a command service is gone. Unregisters its commands. :param svc_ref: A reference to the unbound service :return: True if the commands have been unregistered
[ "Called", "if", "a", "command", "service", "is", "gone", ".", "Unregisters", "its", "commands", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/core.py#L268-L289
tcalmant/ipopo
pelix/shell/core.py
_ShellService.var_set
def var_set(self, session, **kwargs): """ Sets the given variables or prints the current ones. "set answer=42" """ if not kwargs: session.write_line( self._utils.make_table( ("Name", "Value"), session.variables.items() ) ...
python
def var_set(self, session, **kwargs): """ Sets the given variables or prints the current ones. "set answer=42" """ if not kwargs: session.write_line( self._utils.make_table( ("Name", "Value"), session.variables.items() ) ...
[ "def", "var_set", "(", "self", ",", "session", ",", "*", "*", "kwargs", ")", ":", "if", "not", "kwargs", ":", "session", ".", "write_line", "(", "self", ".", "_utils", ".", "make_table", "(", "(", "\"Name\"", ",", "\"Value\"", ")", ",", "session", "....
Sets the given variables or prints the current ones. "set answer=42"
[ "Sets", "the", "given", "variables", "or", "prints", "the", "current", "ones", ".", "set", "answer", "=", "42" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/core.py#L298-L312
tcalmant/ipopo
pelix/shell/core.py
_ShellService.bundle_details
def bundle_details(self, io_handler, bundle_id): """ Prints the details of the bundle with the given ID or name """ bundle = None try: # Convert the given ID into an integer bundle_id = int(bundle_id) except ValueError: # Not an intege...
python
def bundle_details(self, io_handler, bundle_id): """ Prints the details of the bundle with the given ID or name """ bundle = None try: # Convert the given ID into an integer bundle_id = int(bundle_id) except ValueError: # Not an intege...
[ "def", "bundle_details", "(", "self", ",", "io_handler", ",", "bundle_id", ")", ":", "bundle", "=", "None", "try", ":", "# Convert the given ID into an integer", "bundle_id", "=", "int", "(", "bundle_id", ")", "except", "ValueError", ":", "# Not an integer, suppose ...
Prints the details of the bundle with the given ID or name
[ "Prints", "the", "details", "of", "the", "bundle", "with", "the", "given", "ID", "or", "name" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/core.py#L315-L379
tcalmant/ipopo
pelix/shell/core.py
_ShellService.bundles_list
def bundles_list(self, io_handler, name=None): """ Lists the bundles in the framework and their state. Possibility to filter on the bundle name. """ # Head of the table headers = ("ID", "Name", "State", "Version") # Get the bundles bundles = self._context...
python
def bundles_list(self, io_handler, name=None): """ Lists the bundles in the framework and their state. Possibility to filter on the bundle name. """ # Head of the table headers = ("ID", "Name", "State", "Version") # Get the bundles bundles = self._context...
[ "def", "bundles_list", "(", "self", ",", "io_handler", ",", "name", "=", "None", ")", ":", "# Head of the table", "headers", "=", "(", "\"ID\"", ",", "\"Name\"", ",", "\"State\"", ",", "\"Version\"", ")", "# Get the bundles", "bundles", "=", "self", ".", "_c...
Lists the bundles in the framework and their state. Possibility to filter on the bundle name.
[ "Lists", "the", "bundles", "in", "the", "framework", "and", "their", "state", ".", "Possibility", "to", "filter", "on", "the", "bundle", "name", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/core.py#L381-L423
tcalmant/ipopo
pelix/shell/core.py
_ShellService.service_details
def service_details(self, io_handler, service_id): """ Prints the details of the service with the given ID """ svc_ref = self._context.get_service_reference( None, "({0}={1})".format(constants.SERVICE_ID, service_id) ) if svc_ref is None: io_handle...
python
def service_details(self, io_handler, service_id): """ Prints the details of the service with the given ID """ svc_ref = self._context.get_service_reference( None, "({0}={1})".format(constants.SERVICE_ID, service_id) ) if svc_ref is None: io_handle...
[ "def", "service_details", "(", "self", ",", "io_handler", ",", "service_id", ")", ":", "svc_ref", "=", "self", ".", "_context", ".", "get_service_reference", "(", "None", ",", "\"({0}={1})\"", ".", "format", "(", "constants", ".", "SERVICE_ID", ",", "service_i...
Prints the details of the service with the given ID
[ "Prints", "the", "details", "of", "the", "service", "with", "the", "given", "ID" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/core.py#L426-L459
tcalmant/ipopo
pelix/shell/core.py
_ShellService.services_list
def services_list(self, io_handler, specification=None): """ Lists the services in the framework. Possibility to filter on an exact specification. """ # Head of the table headers = ("ID", "Specifications", "Bundle", "Ranking") # Lines references = ( ...
python
def services_list(self, io_handler, specification=None): """ Lists the services in the framework. Possibility to filter on an exact specification. """ # Head of the table headers = ("ID", "Specifications", "Bundle", "Ranking") # Lines references = ( ...
[ "def", "services_list", "(", "self", ",", "io_handler", ",", "specification", "=", "None", ")", ":", "# Head of the table", "headers", "=", "(", "\"ID\"", ",", "\"Specifications\"", ",", "\"Bundle\"", ",", "\"Ranking\"", ")", "# Lines", "references", "=", "(", ...
Lists the services in the framework. Possibility to filter on an exact specification.
[ "Lists", "the", "services", "in", "the", "framework", ".", "Possibility", "to", "filter", "on", "an", "exact", "specification", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/core.py#L461-L496
tcalmant/ipopo
pelix/shell/core.py
_ShellService.properties_list
def properties_list(self, io_handler): """ Lists the properties of the framework """ # Get the framework framework = self._context.get_framework() # Head of the table headers = ("Property Name", "Value") # Lines lines = [item for item in framewor...
python
def properties_list(self, io_handler): """ Lists the properties of the framework """ # Get the framework framework = self._context.get_framework() # Head of the table headers = ("Property Name", "Value") # Lines lines = [item for item in framewor...
[ "def", "properties_list", "(", "self", ",", "io_handler", ")", ":", "# Get the framework", "framework", "=", "self", ".", "_context", ".", "get_framework", "(", ")", "# Head of the table", "headers", "=", "(", "\"Property Name\"", ",", "\"Value\"", ")", "# Lines",...
Lists the properties of the framework
[ "Lists", "the", "properties", "of", "the", "framework" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/core.py#L498-L515
tcalmant/ipopo
pelix/shell/core.py
_ShellService.property_value
def property_value(self, io_handler, name): """ Prints the value of the given property, looking into framework properties then environment variables. """ value = self._context.get_property(name) if value is None: # Avoid printing "None" value = "" ...
python
def property_value(self, io_handler, name): """ Prints the value of the given property, looking into framework properties then environment variables. """ value = self._context.get_property(name) if value is None: # Avoid printing "None" value = "" ...
[ "def", "property_value", "(", "self", ",", "io_handler", ",", "name", ")", ":", "value", "=", "self", ".", "_context", ".", "get_property", "(", "name", ")", "if", "value", "is", "None", ":", "# Avoid printing \"None\"", "value", "=", "\"\"", "io_handler", ...
Prints the value of the given property, looking into framework properties then environment variables.
[ "Prints", "the", "value", "of", "the", "given", "property", "looking", "into", "framework", "properties", "then", "environment", "variables", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/core.py#L517-L527
tcalmant/ipopo
pelix/shell/core.py
_ShellService.environment_list
def environment_list(self, io_handler): """ Lists the framework process environment variables """ # Head of the table headers = ("Environment Variable", "Value") # Lines lines = [item for item in os.environ.items()] # Sort lines lines.sort() ...
python
def environment_list(self, io_handler): """ Lists the framework process environment variables """ # Head of the table headers = ("Environment Variable", "Value") # Lines lines = [item for item in os.environ.items()] # Sort lines lines.sort() ...
[ "def", "environment_list", "(", "self", ",", "io_handler", ")", ":", "# Head of the table", "headers", "=", "(", "\"Environment Variable\"", ",", "\"Value\"", ")", "# Lines", "lines", "=", "[", "item", "for", "item", "in", "os", ".", "environ", ".", "items", ...
Lists the framework process environment variables
[ "Lists", "the", "framework", "process", "environment", "variables" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/core.py#L529-L543
tcalmant/ipopo
pelix/shell/core.py
_ShellService.threads_list
def threads_list(io_handler, max_depth=1): """ Lists the active threads and their current code line """ # Normalize maximum depth try: max_depth = int(max_depth) if max_depth < 1: max_depth = None except (ValueError, TypeError): ...
python
def threads_list(io_handler, max_depth=1): """ Lists the active threads and their current code line """ # Normalize maximum depth try: max_depth = int(max_depth) if max_depth < 1: max_depth = None except (ValueError, TypeError): ...
[ "def", "threads_list", "(", "io_handler", ",", "max_depth", "=", "1", ")", ":", "# Normalize maximum depth", "try", ":", "max_depth", "=", "int", "(", "max_depth", ")", "if", "max_depth", "<", "1", ":", "max_depth", "=", "None", "except", "(", "ValueError", ...
Lists the active threads and their current code line
[ "Lists", "the", "active", "threads", "and", "their", "current", "code", "line" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/core.py#L553-L616
tcalmant/ipopo
pelix/shell/core.py
_ShellService.thread_details
def thread_details(io_handler, thread_id, max_depth=0): """ Prints details about the thread with the given ID (not its name) """ # Normalize maximum depth try: max_depth = int(max_depth) if max_depth < 1: max_depth = None except (Va...
python
def thread_details(io_handler, thread_id, max_depth=0): """ Prints details about the thread with the given ID (not its name) """ # Normalize maximum depth try: max_depth = int(max_depth) if max_depth < 1: max_depth = None except (Va...
[ "def", "thread_details", "(", "io_handler", ",", "thread_id", ",", "max_depth", "=", "0", ")", ":", "# Normalize maximum depth", "try", ":", "max_depth", "=", "int", "(", "max_depth", ")", "if", "max_depth", "<", "1", ":", "max_depth", "=", "None", "except",...
Prints details about the thread with the given ID (not its name)
[ "Prints", "details", "about", "the", "thread", "with", "the", "given", "ID", "(", "not", "its", "name", ")" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/core.py#L619-L674
tcalmant/ipopo
pelix/shell/core.py
_ShellService.log_level
def log_level(io_handler, level=None, name=None): """ Prints/Changes log level """ # Get the logger logger = logging.getLogger(name) # Normalize the name if not name: name = "Root" if not level: # Level not given: print the logger...
python
def log_level(io_handler, level=None, name=None): """ Prints/Changes log level """ # Get the logger logger = logging.getLogger(name) # Normalize the name if not name: name = "Root" if not level: # Level not given: print the logger...
[ "def", "log_level", "(", "io_handler", ",", "level", "=", "None", ",", "name", "=", "None", ")", ":", "# Get the logger", "logger", "=", "logging", ".", "getLogger", "(", "name", ")", "# Normalize the name", "if", "not", "name", ":", "name", "=", "\"Root\"...
Prints/Changes log level
[ "Prints", "/", "Changes", "log", "level" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/core.py#L677-L702
tcalmant/ipopo
pelix/shell/core.py
_ShellService.change_dir
def change_dir(self, session, path): """ Changes the working directory """ if path == "-": # Previous directory path = self._previous_path or "." try: previous = os.getcwd() os.chdir(path) except IOError as ex: ...
python
def change_dir(self, session, path): """ Changes the working directory """ if path == "-": # Previous directory path = self._previous_path or "." try: previous = os.getcwd() os.chdir(path) except IOError as ex: ...
[ "def", "change_dir", "(", "self", ",", "session", ",", "path", ")", ":", "if", "path", "==", "\"-\"", ":", "# Previous directory", "path", "=", "self", ".", "_previous_path", "or", "\".\"", "try", ":", "previous", "=", "os", ".", "getcwd", "(", ")", "o...
Changes the working directory
[ "Changes", "the", "working", "directory" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/core.py#L704-L721
tcalmant/ipopo
pelix/shell/core.py
_ShellService.__get_bundle
def __get_bundle(self, io_handler, bundle_id): """ Retrieves the Bundle object with the given bundle ID. Writes errors through the I/O handler if any. :param io_handler: I/O Handler :param bundle_id: String or integer bundle ID :return: The Bundle object matching the giv...
python
def __get_bundle(self, io_handler, bundle_id): """ Retrieves the Bundle object with the given bundle ID. Writes errors through the I/O handler if any. :param io_handler: I/O Handler :param bundle_id: String or integer bundle ID :return: The Bundle object matching the giv...
[ "def", "__get_bundle", "(", "self", ",", "io_handler", ",", "bundle_id", ")", ":", "try", ":", "bundle_id", "=", "int", "(", "bundle_id", ")", "return", "self", ".", "_context", ".", "get_bundle", "(", "bundle_id", ")", "except", "(", "TypeError", ",", "...
Retrieves the Bundle object with the given bundle ID. Writes errors through the I/O handler if any. :param io_handler: I/O Handler :param bundle_id: String or integer bundle ID :return: The Bundle object matching the given ID, None if not found
[ "Retrieves", "the", "Bundle", "object", "with", "the", "given", "bundle", "ID", ".", "Writes", "errors", "through", "the", "I", "/", "O", "handler", "if", "any", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/core.py#L732-L747
tcalmant/ipopo
pelix/shell/core.py
_ShellService.start
def start(self, io_handler, bundle_id, *bundles_ids): """ Starts the bundles with the given IDs. Stops on first failure. """ for bid in (bundle_id,) + bundles_ids: try: # Got an int => it's a bundle ID bid = int(bid) except ValueErr...
python
def start(self, io_handler, bundle_id, *bundles_ids): """ Starts the bundles with the given IDs. Stops on first failure. """ for bid in (bundle_id,) + bundles_ids: try: # Got an int => it's a bundle ID bid = int(bid) except ValueErr...
[ "def", "start", "(", "self", ",", "io_handler", ",", "bundle_id", ",", "*", "bundles_ids", ")", ":", "for", "bid", "in", "(", "bundle_id", ",", ")", "+", "bundles_ids", ":", "try", ":", "# Got an int => it's a bundle ID", "bid", "=", "int", "(", "bid", "...
Starts the bundles with the given IDs. Stops on first failure.
[ "Starts", "the", "bundles", "with", "the", "given", "IDs", ".", "Stops", "on", "first", "failure", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/core.py#L750-L773
tcalmant/ipopo
pelix/shell/core.py
_ShellService.stop
def stop(self, io_handler, bundle_id, *bundles_ids): """ Stops the bundles with the given IDs. Stops on first failure. """ for bid in (bundle_id,) + bundles_ids: bundle = self.__get_bundle(io_handler, bid) if bundle is not None: io_handler.write_li...
python
def stop(self, io_handler, bundle_id, *bundles_ids): """ Stops the bundles with the given IDs. Stops on first failure. """ for bid in (bundle_id,) + bundles_ids: bundle = self.__get_bundle(io_handler, bid) if bundle is not None: io_handler.write_li...
[ "def", "stop", "(", "self", ",", "io_handler", ",", "bundle_id", ",", "*", "bundles_ids", ")", ":", "for", "bid", "in", "(", "bundle_id", ",", ")", "+", "bundles_ids", ":", "bundle", "=", "self", ".", "__get_bundle", "(", "io_handler", ",", "bid", ")",...
Stops the bundles with the given IDs. Stops on first failure.
[ "Stops", "the", "bundles", "with", "the", "given", "IDs", ".", "Stops", "on", "first", "failure", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/core.py#L776-L792
tcalmant/ipopo
pelix/shell/core.py
_ShellService.install
def install(self, io_handler, module_name): """ Installs the bundle with the given module name """ bundle = self._context.install_bundle(module_name) io_handler.write_line("Bundle ID: {0}", bundle.get_bundle_id()) return bundle.get_bundle_id()
python
def install(self, io_handler, module_name): """ Installs the bundle with the given module name """ bundle = self._context.install_bundle(module_name) io_handler.write_line("Bundle ID: {0}", bundle.get_bundle_id()) return bundle.get_bundle_id()
[ "def", "install", "(", "self", ",", "io_handler", ",", "module_name", ")", ":", "bundle", "=", "self", ".", "_context", ".", "install_bundle", "(", "module_name", ")", "io_handler", ".", "write_line", "(", "\"Bundle ID: {0}\"", ",", "bundle", ".", "get_bundle_...
Installs the bundle with the given module name
[ "Installs", "the", "bundle", "with", "the", "given", "module", "name" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/core.py#L813-L819
tcalmant/ipopo
pelix/ipopo/handlers/temporal.py
_HandlerFactory._prepare_configs
def _prepare_configs(configs, requires_filters, temporal_timeouts): """ Overrides the filters specified in the decorator with the given ones :param configs: Field → (Requirement, key, allow_none) dictionary :param requires_filters: Content of the 'requires.filter' component ...
python
def _prepare_configs(configs, requires_filters, temporal_timeouts): """ Overrides the filters specified in the decorator with the given ones :param configs: Field → (Requirement, key, allow_none) dictionary :param requires_filters: Content of the 'requires.filter' component ...
[ "def", "_prepare_configs", "(", "configs", ",", "requires_filters", ",", "temporal_timeouts", ")", ":", "if", "not", "isinstance", "(", "requires_filters", ",", "dict", ")", ":", "requires_filters", "=", "{", "}", "if", "not", "isinstance", "(", "temporal_timeou...
Overrides the filters specified in the decorator with the given ones :param configs: Field → (Requirement, key, allow_none) dictionary :param requires_filters: Content of the 'requires.filter' component property (field → string) :param temporal_timeouts: Content...
[ "Overrides", "the", "filters", "specified", "in", "the", "decorator", "with", "the", "given", "ones" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/handlers/temporal.py#L59-L111
tcalmant/ipopo
pelix/ipopo/handlers/temporal.py
_HandlerFactory.get_handlers
def get_handlers(self, component_context, instance): """ Sets up service providers for the given component :param component_context: The ComponentContext bean :param instance: The component instance :return: The list of handlers associated to the given component """ ...
python
def get_handlers(self, component_context, instance): """ Sets up service providers for the given component :param component_context: The ComponentContext bean :param instance: The component instance :return: The list of handlers associated to the given component """ ...
[ "def", "get_handlers", "(", "self", ",", "component_context", ",", "instance", ")", ":", "# Extract information from the context", "configs", "=", "component_context", ".", "get_handler", "(", "ipopo_constants", ".", "HANDLER_TEMPORAL", ")", "requires_filters", "=", "co...
Sets up service providers for the given component :param component_context: The ComponentContext bean :param instance: The component instance :return: The list of handlers associated to the given component
[ "Sets", "up", "service", "providers", "for", "the", "given", "component" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/handlers/temporal.py#L113-L141
tcalmant/ipopo
pelix/ipopo/handlers/temporal.py
TemporalDependency.clear
def clear(self): """ Cleans up the manager. The manager can't be used after this method has been called """ # Cancel timer self.__cancel_timer() self.__timer = None self.__timer_args = None self.__still_valid = False self._value = None ...
python
def clear(self): """ Cleans up the manager. The manager can't be used after this method has been called """ # Cancel timer self.__cancel_timer() self.__timer = None self.__timer_args = None self.__still_valid = False self._value = None ...
[ "def", "clear", "(", "self", ")", ":", "# Cancel timer", "self", ".", "__cancel_timer", "(", ")", "self", ".", "__timer", "=", "None", "self", ".", "__timer_args", "=", "None", "self", ".", "__still_valid", "=", "False", "self", ".", "_value", "=", "None...
Cleans up the manager. The manager can't be used after this method has been called
[ "Cleans", "up", "the", "manager", ".", "The", "manager", "can", "t", "be", "used", "after", "this", "method", "has", "been", "called" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/handlers/temporal.py#L275-L287
tcalmant/ipopo
pelix/ipopo/handlers/temporal.py
TemporalDependency.on_service_arrival
def on_service_arrival(self, svc_ref): """ Called when a service has been registered in the framework :param svc_ref: A service reference """ with self._lock: if self.reference is None: # Inject the service service = self._context.get_...
python
def on_service_arrival(self, svc_ref): """ Called when a service has been registered in the framework :param svc_ref: A service reference """ with self._lock: if self.reference is None: # Inject the service service = self._context.get_...
[ "def", "on_service_arrival", "(", "self", ",", "svc_ref", ")", ":", "with", "self", ".", "_lock", ":", "if", "self", ".", "reference", "is", "None", ":", "# Inject the service", "service", "=", "self", ".", "_context", ".", "get_service", "(", "svc_ref", "...
Called when a service has been registered in the framework :param svc_ref: A service reference
[ "Called", "when", "a", "service", "has", "been", "registered", "in", "the", "framework" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/handlers/temporal.py#L289-L310
tcalmant/ipopo
pelix/ipopo/handlers/temporal.py
TemporalDependency.on_service_departure
def on_service_departure(self, svc_ref): """ Called when a service has been unregistered from the framework :param svc_ref: A service reference """ with self._lock: if svc_ref is self.reference: # Forget about the service self._value.u...
python
def on_service_departure(self, svc_ref): """ Called when a service has been unregistered from the framework :param svc_ref: A service reference """ with self._lock: if svc_ref is self.reference: # Forget about the service self._value.u...
[ "def", "on_service_departure", "(", "self", ",", "svc_ref", ")", ":", "with", "self", ".", "_lock", ":", "if", "svc_ref", "is", "self", ".", "reference", ":", "# Forget about the service", "self", ".", "_value", ".", "unset_service", "(", ")", "# Clear the ref...
Called when a service has been unregistered from the framework :param svc_ref: A service reference
[ "Called", "when", "a", "service", "has", "been", "unregistered", "from", "the", "framework" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/handlers/temporal.py#L312-L345
tcalmant/ipopo
pelix/ipopo/handlers/temporal.py
TemporalDependency.__cancel_timer
def __cancel_timer(self): """ Cancels the timer, and calls its target method immediately """ if self.__timer is not None: self.__timer.cancel() self.__unbind_call(True) self.__timer_args = None self.__timer = None
python
def __cancel_timer(self): """ Cancels the timer, and calls its target method immediately """ if self.__timer is not None: self.__timer.cancel() self.__unbind_call(True) self.__timer_args = None self.__timer = None
[ "def", "__cancel_timer", "(", "self", ")", ":", "if", "self", ".", "__timer", "is", "not", "None", ":", "self", ".", "__timer", ".", "cancel", "(", ")", "self", ".", "__unbind_call", "(", "True", ")", "self", ".", "__timer_args", "=", "None", "self", ...
Cancels the timer, and calls its target method immediately
[ "Cancels", "the", "timer", "and", "calls", "its", "target", "method", "immediately" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/handlers/temporal.py#L347-L356
tcalmant/ipopo
pelix/ipopo/handlers/temporal.py
TemporalDependency.__unbind_call
def __unbind_call(self, still_valid): """ Calls the iPOPO unbind method """ with self._lock: if self.__timer is not None: # Timeout expired, we're not valid anymore self.__timer = None self.__still_valid = still_valid ...
python
def __unbind_call(self, still_valid): """ Calls the iPOPO unbind method """ with self._lock: if self.__timer is not None: # Timeout expired, we're not valid anymore self.__timer = None self.__still_valid = still_valid ...
[ "def", "__unbind_call", "(", "self", ",", "still_valid", ")", ":", "with", "self", ".", "_lock", ":", "if", "self", ".", "__timer", "is", "not", "None", ":", "# Timeout expired, we're not valid anymore", "self", ".", "__timer", "=", "None", "self", ".", "__s...
Calls the iPOPO unbind method
[ "Calls", "the", "iPOPO", "unbind", "method" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/handlers/temporal.py#L358-L369
tcalmant/ipopo
pelix/remote/transport/jabsorb_rpc.py
_JabsorbRpcServlet.do_POST
def do_POST(self, request, response): # pylint: disable=C0103 """ Handle a POST request :param request: The HTTP request bean :param response: The HTTP response handler """ # Get the request JSON content data = jsonrpclib.loads(to_str(request.read_data())...
python
def do_POST(self, request, response): # pylint: disable=C0103 """ Handle a POST request :param request: The HTTP request bean :param response: The HTTP response handler """ # Get the request JSON content data = jsonrpclib.loads(to_str(request.read_data())...
[ "def", "do_POST", "(", "self", ",", "request", ",", "response", ")", ":", "# pylint: disable=C0103", "# Get the request JSON content", "data", "=", "jsonrpclib", ".", "loads", "(", "to_str", "(", "request", ".", "read_data", "(", ")", ")", ")", "# Convert from J...
Handle a POST request :param request: The HTTP request bean :param response: The HTTP response handler
[ "Handle", "a", "POST", "request" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/remote/transport/jabsorb_rpc.py#L124-L157
tcalmant/ipopo
pelix/http/routing.py
RestDispatcher._rest_dispatch
def _rest_dispatch(self, request, response): # type: (AbstractHTTPServletRequest, AbstractHTTPServletResponse) -> None """ Dispatches the request :param request: Request bean :param response: Response bean """ # Extract request information http_verb = req...
python
def _rest_dispatch(self, request, response): # type: (AbstractHTTPServletRequest, AbstractHTTPServletResponse) -> None """ Dispatches the request :param request: Request bean :param response: Response bean """ # Extract request information http_verb = req...
[ "def", "_rest_dispatch", "(", "self", ",", "request", ",", "response", ")", ":", "# type: (AbstractHTTPServletRequest, AbstractHTTPServletResponse) -> None", "# Extract request information", "http_verb", "=", "request", ".", "get_command", "(", ")", "sub_path", "=", "reques...
Dispatches the request :param request: Request bean :param response: Response bean
[ "Dispatches", "the", "request" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/http/routing.py#L280-L364
tcalmant/ipopo
pelix/http/routing.py
RestDispatcher._setup_rest_dispatcher
def _setup_rest_dispatcher(self): """ Finds all methods to call when handling a route """ for _, method in inspect.getmembers(self, inspect.isroutine): try: config = getattr(method, HTTP_ROUTE_ATTRIBUTE) except AttributeError: # Not...
python
def _setup_rest_dispatcher(self): """ Finds all methods to call when handling a route """ for _, method in inspect.getmembers(self, inspect.isroutine): try: config = getattr(method, HTTP_ROUTE_ATTRIBUTE) except AttributeError: # Not...
[ "def", "_setup_rest_dispatcher", "(", "self", ")", ":", "for", "_", ",", "method", "in", "inspect", ".", "getmembers", "(", "self", ",", "inspect", ".", "isroutine", ")", ":", "try", ":", "config", "=", "getattr", "(", "method", ",", "HTTP_ROUTE_ATTRIBUTE"...
Finds all methods to call when handling a route
[ "Finds", "all", "methods", "to", "call", "when", "handling", "a", "route" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/http/routing.py#L366-L381
tcalmant/ipopo
pelix/http/routing.py
RestDispatcher.__convert_route
def __convert_route(route): # type: (str) -> Tuple[Pattern[str], Dict[str, Callable[[str], Any]]] """ Converts a route pattern into a regex. The result is a tuple containing the regex pattern to match and a dictionary associating arguments names and their converter (if any) ...
python
def __convert_route(route): # type: (str) -> Tuple[Pattern[str], Dict[str, Callable[[str], Any]]] """ Converts a route pattern into a regex. The result is a tuple containing the regex pattern to match and a dictionary associating arguments names and their converter (if any) ...
[ "def", "__convert_route", "(", "route", ")", ":", "# type: (str) -> Tuple[Pattern[str], Dict[str, Callable[[str], Any]]]", "arguments", "=", "{", "}", "# type: Dict[str, Callable[[str], Any]]", "last_idx", "=", "0", "final_pattern", "=", "[", "]", "match_iter", "=", "_MARKE...
Converts a route pattern into a regex. The result is a tuple containing the regex pattern to match and a dictionary associating arguments names and their converter (if any) A route can be: "/hello/<name>/<age:int>" :param route: A route string, i.e. a path with type markers :re...
[ "Converts", "a", "route", "pattern", "into", "a", "regex", ".", "The", "result", "is", "a", "tuple", "containing", "the", "regex", "pattern", "to", "match", "and", "a", "dictionary", "associating", "arguments", "names", "and", "their", "converter", "(", "if"...
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/http/routing.py#L384-L436
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.check_event
def check_event(self, event): # type: (ServiceEvent) -> bool """ Tests if the given service event must be handled or ignored, based on the state of the iPOPO service and on the content of the event. :param event: A service event :return: True if the event can be handled,...
python
def check_event(self, event): # type: (ServiceEvent) -> bool """ Tests if the given service event must be handled or ignored, based on the state of the iPOPO service and on the content of the event. :param event: A service event :return: True if the event can be handled,...
[ "def", "check_event", "(", "self", ",", "event", ")", ":", "# type: (ServiceEvent) -> bool", "with", "self", ".", "_lock", ":", "if", "self", ".", "state", "==", "StoredInstance", ".", "KILLED", ":", "# This call may have been blocked by the internal state lock,", "# ...
Tests if the given service event must be handled or ignored, based on the state of the iPOPO service and on the content of the event. :param event: A service event :return: True if the event can be handled, False if it must be ignored
[ "Tests", "if", "the", "given", "service", "event", "must", "be", "handled", "or", "ignored", "based", "on", "the", "state", "of", "the", "iPOPO", "service", "and", "on", "the", "content", "of", "the", "event", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L167-L182
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.bind
def bind(self, dependency, svc, svc_ref): # type: (Any, Any, ServiceReference) -> None """ Called by a dependency manager to inject a new service and update the component life cycle. """ with self._lock: self.__set_binding(dependency, svc, svc_ref) ...
python
def bind(self, dependency, svc, svc_ref): # type: (Any, Any, ServiceReference) -> None """ Called by a dependency manager to inject a new service and update the component life cycle. """ with self._lock: self.__set_binding(dependency, svc, svc_ref) ...
[ "def", "bind", "(", "self", ",", "dependency", ",", "svc", ",", "svc_ref", ")", ":", "# type: (Any, Any, ServiceReference) -> None", "with", "self", ".", "_lock", ":", "self", ".", "__set_binding", "(", "dependency", ",", "svc", ",", "svc_ref", ")", "self", ...
Called by a dependency manager to inject a new service and update the component life cycle.
[ "Called", "by", "a", "dependency", "manager", "to", "inject", "a", "new", "service", "and", "update", "the", "component", "life", "cycle", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L184-L192
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.update
def update(self, dependency, svc, svc_ref, old_properties, new_value=False): # type: (Any, Any, ServiceReference, dict, bool) -> None """ Called by a dependency manager when the properties of an injected dependency have been updated. :param dependency: The dependency handler ...
python
def update(self, dependency, svc, svc_ref, old_properties, new_value=False): # type: (Any, Any, ServiceReference, dict, bool) -> None """ Called by a dependency manager when the properties of an injected dependency have been updated. :param dependency: The dependency handler ...
[ "def", "update", "(", "self", ",", "dependency", ",", "svc", ",", "svc_ref", ",", "old_properties", ",", "new_value", "=", "False", ")", ":", "# type: (Any, Any, ServiceReference, dict, bool) -> None", "with", "self", ".", "_lock", ":", "self", ".", "__update_bind...
Called by a dependency manager when the properties of an injected dependency have been updated. :param dependency: The dependency handler :param svc: The injected service :param svc_ref: The reference of the injected service :param old_properties: Previous properties of the depe...
[ "Called", "by", "a", "dependency", "manager", "when", "the", "properties", "of", "an", "injected", "dependency", "have", "been", "updated", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L194-L210
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.unbind
def unbind(self, dependency, svc, svc_ref): # type: (Any, Any, ServiceReference) -> None """ Called by a dependency manager to remove an injected service and to update the component life cycle. """ with self._lock: # Invalidate first (if needed) se...
python
def unbind(self, dependency, svc, svc_ref): # type: (Any, Any, ServiceReference) -> None """ Called by a dependency manager to remove an injected service and to update the component life cycle. """ with self._lock: # Invalidate first (if needed) se...
[ "def", "unbind", "(", "self", ",", "dependency", ",", "svc", ",", "svc_ref", ")", ":", "# type: (Any, Any, ServiceReference) -> None", "with", "self", ".", "_lock", ":", "# Invalidate first (if needed)", "self", ".", "check_lifecycle", "(", ")", "# Call unbind() and r...
Called by a dependency manager to remove an injected service and to update the component life cycle.
[ "Called", "by", "a", "dependency", "manager", "to", "remove", "an", "injected", "service", "and", "to", "update", "the", "component", "life", "cycle", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L212-L227
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.set_controller_state
def set_controller_state(self, name, value): # type: (str, bool) -> None """ Sets the state of the controller with the given name :param name: The name of the controller :param value: The new value of the controller """ with self._lock: self._controll...
python
def set_controller_state(self, name, value): # type: (str, bool) -> None """ Sets the state of the controller with the given name :param name: The name of the controller :param value: The new value of the controller """ with self._lock: self._controll...
[ "def", "set_controller_state", "(", "self", ",", "name", ",", "value", ")", ":", "# type: (str, bool) -> None", "with", "self", ".", "_lock", ":", "self", ".", "_controllers_state", "[", "name", "]", "=", "value", "self", ".", "__safe_handlers_callback", "(", ...
Sets the state of the controller with the given name :param name: The name of the controller :param value: The new value of the controller
[ "Sets", "the", "state", "of", "the", "controller", "with", "the", "given", "name" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L240-L250
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.update_property
def update_property(self, name, old_value, new_value): # type: (str, Any, Any) -> None """ Handles a property changed event :param name: The changed property name :param old_value: The previous property value :param new_value: The new property value """ w...
python
def update_property(self, name, old_value, new_value): # type: (str, Any, Any) -> None """ Handles a property changed event :param name: The changed property name :param old_value: The previous property value :param new_value: The new property value """ w...
[ "def", "update_property", "(", "self", ",", "name", ",", "old_value", ",", "new_value", ")", ":", "# type: (str, Any, Any) -> None", "with", "self", ".", "_lock", ":", "self", ".", "__safe_handlers_callback", "(", "\"on_property_change\"", ",", "name", ",", "old_v...
Handles a property changed event :param name: The changed property name :param old_value: The previous property value :param new_value: The new property value
[ "Handles", "a", "property", "changed", "event" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L252-L264
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.update_hidden_property
def update_hidden_property(self, name, old_value, new_value): # type: (str, Any, Any) -> None """ Handles an hidden property changed event :param name: The changed property name :param old_value: The previous property value :param new_value: The new property value ...
python
def update_hidden_property(self, name, old_value, new_value): # type: (str, Any, Any) -> None """ Handles an hidden property changed event :param name: The changed property name :param old_value: The previous property value :param new_value: The new property value ...
[ "def", "update_hidden_property", "(", "self", ",", "name", ",", "old_value", ",", "new_value", ")", ":", "# type: (str, Any, Any) -> None", "with", "self", ".", "_lock", ":", "self", ".", "__safe_handlers_callback", "(", "\"on_hidden_property_change\"", ",", "name", ...
Handles an hidden property changed event :param name: The changed property name :param old_value: The previous property value :param new_value: The new property value
[ "Handles", "an", "hidden", "property", "changed", "event" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L266-L278
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.get_handlers
def get_handlers(self, kind=None): """ Retrieves the handlers of the given kind. If kind is None, all handlers are returned. :param kind: The kind of the handlers to return :return: A list of handlers, or an empty list """ with self._lock: if kind is ...
python
def get_handlers(self, kind=None): """ Retrieves the handlers of the given kind. If kind is None, all handlers are returned. :param kind: The kind of the handlers to return :return: A list of handlers, or an empty list """ with self._lock: if kind is ...
[ "def", "get_handlers", "(", "self", ",", "kind", "=", "None", ")", ":", "with", "self", ".", "_lock", ":", "if", "kind", "is", "not", "None", ":", "try", ":", "return", "self", ".", "_handlers", "[", "kind", "]", "[", ":", "]", "except", "KeyError"...
Retrieves the handlers of the given kind. If kind is None, all handlers are returned. :param kind: The kind of the handlers to return :return: A list of handlers, or an empty list
[ "Retrieves", "the", "handlers", "of", "the", "given", "kind", ".", "If", "kind", "is", "None", "all", "handlers", "are", "returned", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L280-L295
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.check_lifecycle
def check_lifecycle(self): """ Tests if the state of the component must be updated, based on its own state and on the state of its dependencies """ with self._lock: # Validation flags was_valid = self.state == StoredInstance.VALID can_validate ...
python
def check_lifecycle(self): """ Tests if the state of the component must be updated, based on its own state and on the state of its dependencies """ with self._lock: # Validation flags was_valid = self.state == StoredInstance.VALID can_validate ...
[ "def", "check_lifecycle", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "# Validation flags", "was_valid", "=", "self", ".", "state", "==", "StoredInstance", ".", "VALID", "can_validate", "=", "self", ".", "state", "not", "in", "(", "StoredInstan...
Tests if the state of the component must be updated, based on its own state and on the state of its dependencies
[ "Tests", "if", "the", "state", "of", "the", "component", "must", "be", "updated", "based", "on", "its", "own", "state", "and", "on", "the", "state", "of", "its", "dependencies" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L297-L322
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.update_bindings
def update_bindings(self): # type: () -> bool """ Updates the bindings of the given component :return: True if the component can be validated """ with self._lock: all_valid = True for handler in self.get_handlers(handlers_const.KIND_DEPENDENCY): ...
python
def update_bindings(self): # type: () -> bool """ Updates the bindings of the given component :return: True if the component can be validated """ with self._lock: all_valid = True for handler in self.get_handlers(handlers_const.KIND_DEPENDENCY): ...
[ "def", "update_bindings", "(", "self", ")", ":", "# type: () -> bool", "with", "self", ".", "_lock", ":", "all_valid", "=", "True", "for", "handler", "in", "self", ".", "get_handlers", "(", "handlers_const", ".", "KIND_DEPENDENCY", ")", ":", "# Try to bind", "...
Updates the bindings of the given component :return: True if the component can be validated
[ "Updates", "the", "bindings", "of", "the", "given", "component" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L324-L341
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.retry_erroneous
def retry_erroneous(self, properties_update): # type: (dict) -> int """ Removes the ERRONEOUS state from a component and retries a validation :param properties_update: A dictionary to update component properties :return: The new state of the component """ with se...
python
def retry_erroneous(self, properties_update): # type: (dict) -> int """ Removes the ERRONEOUS state from a component and retries a validation :param properties_update: A dictionary to update component properties :return: The new state of the component """ with se...
[ "def", "retry_erroneous", "(", "self", ",", "properties_update", ")", ":", "# type: (dict) -> int", "with", "self", ".", "_lock", ":", "if", "self", ".", "state", "!=", "StoredInstance", ".", "ERRONEOUS", ":", "# Not in erroneous state: ignore", "return", "self", ...
Removes the ERRONEOUS state from a component and retries a validation :param properties_update: A dictionary to update component properties :return: The new state of the component
[ "Removes", "the", "ERRONEOUS", "state", "from", "a", "component", "and", "retries", "a", "validation" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L350-L375
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.invalidate
def invalidate(self, callback=True): # type: (bool) -> bool """ Applies the component invalidation. :param callback: If True, call back the component before the invalidation :return: False if the component wasn't valid """ with self._lock...
python
def invalidate(self, callback=True): # type: (bool) -> bool """ Applies the component invalidation. :param callback: If True, call back the component before the invalidation :return: False if the component wasn't valid """ with self._lock...
[ "def", "invalidate", "(", "self", ",", "callback", "=", "True", ")", ":", "# type: (bool) -> bool", "with", "self", ".", "_lock", ":", "if", "self", ".", "state", "!=", "StoredInstance", ".", "VALID", ":", "# Instance is not running...", "return", "False", "# ...
Applies the component invalidation. :param callback: If True, call back the component before the invalidation :return: False if the component wasn't valid
[ "Applies", "the", "component", "invalidation", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L377-L413
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.kill
def kill(self): # type: () -> bool """ This instance is killed : invalidate it if needed, clean up all members When this method is called, this StoredInstance object must have been removed from the registry :return: True if the component has been killed, False if it alr...
python
def kill(self): # type: () -> bool """ This instance is killed : invalidate it if needed, clean up all members When this method is called, this StoredInstance object must have been removed from the registry :return: True if the component has been killed, False if it alr...
[ "def", "kill", "(", "self", ")", ":", "# type: () -> bool", "with", "self", ".", "_lock", ":", "# Already dead...", "if", "self", ".", "state", "==", "StoredInstance", ".", "KILLED", ":", "return", "False", "try", ":", "self", ".", "invalidate", "(", "True...
This instance is killed : invalidate it if needed, clean up all members When this method is called, this StoredInstance object must have been removed from the registry :return: True if the component has been killed, False if it already was
[ "This", "instance", "is", "killed", ":", "invalidate", "it", "if", "needed", "clean", "up", "all", "members" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L415-L475
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.validate
def validate(self, safe_callback=True): # type: (bool) -> bool """ Ends the component validation, registering services :param safe_callback: If True, calls the component validation callback :return: True if the component has been validated, else False :raise RuntimeError...
python
def validate(self, safe_callback=True): # type: (bool) -> bool """ Ends the component validation, registering services :param safe_callback: If True, calls the component validation callback :return: True if the component has been validated, else False :raise RuntimeError...
[ "def", "validate", "(", "self", ",", "safe_callback", "=", "True", ")", ":", "# type: (bool) -> bool", "with", "self", ".", "_lock", ":", "if", "self", ".", "state", "in", "(", "StoredInstance", ".", "VALID", ",", "StoredInstance", ".", "VALIDATING", ",", ...
Ends the component validation, registering services :param safe_callback: If True, calls the component validation callback :return: True if the component has been validated, else False :raise RuntimeError: You try to awake a dead component
[ "Ends", "the", "component", "validation", "registering", "services" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L477-L533
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.__callback
def __callback(self, event, *args, **kwargs): # type: (str, *Any, **Any) -> Any """ Calls the registered method in the component for the given event :param event: An event (IPOPO_CALLBACK_VALIDATE, ...) :return: The callback result, or None :raise Exception: Something we...
python
def __callback(self, event, *args, **kwargs): # type: (str, *Any, **Any) -> Any """ Calls the registered method in the component for the given event :param event: An event (IPOPO_CALLBACK_VALIDATE, ...) :return: The callback result, or None :raise Exception: Something we...
[ "def", "__callback", "(", "self", ",", "event", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# type: (str, *Any, **Any) -> Any", "comp_callback", "=", "self", ".", "context", ".", "get_callback", "(", "event", ")", "if", "not", "comp_callback", ":",...
Calls the registered method in the component for the given event :param event: An event (IPOPO_CALLBACK_VALIDATE, ...) :return: The callback result, or None :raise Exception: Something went wrong
[ "Calls", "the", "registered", "method", "in", "the", "component", "for", "the", "given", "event" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L535-L555
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.__validation_callback
def __validation_callback(self, event): # type: (str) -> Any """ Specific handling for the ``@ValidateComponent`` and ``@InvalidateComponent`` callback, as it requires checking arguments count and order :param event: The kind of life-cycle callback (in/validation) ...
python
def __validation_callback(self, event): # type: (str) -> Any """ Specific handling for the ``@ValidateComponent`` and ``@InvalidateComponent`` callback, as it requires checking arguments count and order :param event: The kind of life-cycle callback (in/validation) ...
[ "def", "__validation_callback", "(", "self", ",", "event", ")", ":", "# type: (str) -> Any", "comp_callback", "=", "self", ".", "context", ".", "get_callback", "(", "event", ")", "if", "not", "comp_callback", ":", "# No registered callback", "return", "True", "# G...
Specific handling for the ``@ValidateComponent`` and ``@InvalidateComponent`` callback, as it requires checking arguments count and order :param event: The kind of life-cycle callback (in/validation) :return: The callback result, or None :raise Exception: Something went wrong
[ "Specific", "handling", "for", "the", "@ValidateComponent", "and", "@InvalidateComponent", "callback", "as", "it", "requires", "checking", "arguments", "count", "and", "order" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L557-L595
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.__field_callback
def __field_callback(self, field, event, *args, **kwargs): # type: (str, str, *Any, **Any) -> Any """ Calls the registered method in the component for the given field event :param field: A field name :param event: An event (IPOPO_CALLBACK_VALIDATE, ...) :return: The call...
python
def __field_callback(self, field, event, *args, **kwargs): # type: (str, str, *Any, **Any) -> Any """ Calls the registered method in the component for the given field event :param field: A field name :param event: An event (IPOPO_CALLBACK_VALIDATE, ...) :return: The call...
[ "def", "__field_callback", "(", "self", ",", "field", ",", "event", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# type: (str, str, *Any, **Any) -> Any", "# Get the field callback info", "cb_info", "=", "self", ".", "context", ".", "get_field_callback", "...
Calls the registered method in the component for the given field event :param field: A field name :param event: An event (IPOPO_CALLBACK_VALIDATE, ...) :return: The callback result, or None :raise Exception: Something went wrong
[ "Calls", "the", "registered", "method", "in", "the", "component", "for", "the", "given", "field", "event" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L597-L626
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.safe_callback
def safe_callback(self, event, *args, **kwargs): # type: (str, *Any, **Any) -> Any """ Calls the registered method in the component for the given event, ignoring raised exceptions :param event: An event (IPOPO_CALLBACK_VALIDATE, ...) :return: The callback result, or None...
python
def safe_callback(self, event, *args, **kwargs): # type: (str, *Any, **Any) -> Any """ Calls the registered method in the component for the given event, ignoring raised exceptions :param event: An event (IPOPO_CALLBACK_VALIDATE, ...) :return: The callback result, or None...
[ "def", "safe_callback", "(", "self", ",", "event", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# type: (str, *Any, **Any) -> Any", "if", "self", ".", "state", "==", "StoredInstance", ".", "KILLED", ":", "# Invalid state", "return", "None", "try", "...
Calls the registered method in the component for the given event, ignoring raised exceptions :param event: An event (IPOPO_CALLBACK_VALIDATE, ...) :return: The callback result, or None
[ "Calls", "the", "registered", "method", "in", "the", "component", "for", "the", "given", "event", "ignoring", "raised", "exceptions" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L628-L665
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.__safe_validation_callback
def __safe_validation_callback(self, event): # type: (str) -> Any """ Calls the ``@ValidateComponent`` or ``@InvalidateComponent`` callback, ignoring raised exceptions :param event: The kind of life-cycle callback (in/validation) :return: The callback result, or None ...
python
def __safe_validation_callback(self, event): # type: (str) -> Any """ Calls the ``@ValidateComponent`` or ``@InvalidateComponent`` callback, ignoring raised exceptions :param event: The kind of life-cycle callback (in/validation) :return: The callback result, or None ...
[ "def", "__safe_validation_callback", "(", "self", ",", "event", ")", ":", "# type: (str) -> Any", "if", "self", ".", "state", "==", "StoredInstance", ".", "KILLED", ":", "# Invalid state", "return", "None", "try", ":", "return", "self", ".", "__validation_callback...
Calls the ``@ValidateComponent`` or ``@InvalidateComponent`` callback, ignoring raised exceptions :param event: The kind of life-cycle callback (in/validation) :return: The callback result, or None
[ "Calls", "the", "@ValidateComponent", "or", "@InvalidateComponent", "callback", "ignoring", "raised", "exceptions" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L667-L710
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.__safe_handler_callback
def __safe_handler_callback(self, handler, method_name, *args, **kwargs): # type: (Any, str, *Any, **Any) -> Any """ Calls the given method with the given arguments in the given handler. Logs exceptions, but doesn't propagate them. Special arguments can be given in kwargs: ...
python
def __safe_handler_callback(self, handler, method_name, *args, **kwargs): # type: (Any, str, *Any, **Any) -> Any """ Calls the given method with the given arguments in the given handler. Logs exceptions, but doesn't propagate them. Special arguments can be given in kwargs: ...
[ "def", "__safe_handler_callback", "(", "self", ",", "handler", ",", "method_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# type: (Any, str, *Any, **Any) -> Any", "if", "handler", "is", "None", "or", "method_name", "is", "None", ":", "return", "...
Calls the given method with the given arguments in the given handler. Logs exceptions, but doesn't propagate them. Special arguments can be given in kwargs: * 'none_as_true': If set to True and the method returned None or doesn't exist, the result is considered as Tru...
[ "Calls", "the", "given", "method", "with", "the", "given", "arguments", "in", "the", "given", "handler", ".", "Logs", "exceptions", "but", "doesn", "t", "propagate", "them", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L753-L810
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.__safe_handlers_callback
def __safe_handlers_callback(self, method_name, *args, **kwargs): # type: (str, *Any, **Any) -> bool """ Calls the given method with the given arguments in all handlers. Logs exceptions, but doesn't propagate them. Methods called in handlers must return None, True or False. ...
python
def __safe_handlers_callback(self, method_name, *args, **kwargs): # type: (str, *Any, **Any) -> bool """ Calls the given method with the given arguments in all handlers. Logs exceptions, but doesn't propagate them. Methods called in handlers must return None, True or False. ...
[ "def", "__safe_handlers_callback", "(", "self", ",", "method_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# type: (str, *Any, **Any) -> bool", "if", "self", ".", "state", "==", "StoredInstance", ".", "KILLED", ":", "# Nothing to do", "return", "F...
Calls the given method with the given arguments in all handlers. Logs exceptions, but doesn't propagate them. Methods called in handlers must return None, True or False. Special parameters can be given in kwargs: * 'exception_as_error': if it is set to True and an exception is raised ...
[ "Calls", "the", "given", "method", "with", "the", "given", "arguments", "in", "all", "handlers", ".", "Logs", "exceptions", "but", "doesn", "t", "propagate", "them", ".", "Methods", "called", "in", "handlers", "must", "return", "None", "True", "or", "False",...
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L812-L870
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.__set_binding
def __set_binding(self, dependency, service, reference): # type: (Any, Any, ServiceReference) -> None """ Injects a service in the component :param dependency: The dependency handler :param service: The injected service :param reference: The reference of the injected ser...
python
def __set_binding(self, dependency, service, reference): # type: (Any, Any, ServiceReference) -> None """ Injects a service in the component :param dependency: The dependency handler :param service: The injected service :param reference: The reference of the injected ser...
[ "def", "__set_binding", "(", "self", ",", "dependency", ",", "service", ",", "reference", ")", ":", "# type: (Any, Any, ServiceReference) -> None", "# Set the value", "setattr", "(", "self", ".", "instance", ",", "dependency", ".", "get_field", "(", ")", ",", "dep...
Injects a service in the component :param dependency: The dependency handler :param service: The injected service :param reference: The reference of the injected service
[ "Injects", "a", "service", "in", "the", "component" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L872-L892
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.__update_binding
def __update_binding( self, dependency, service, reference, old_properties, new_value ): # type: (Any, Any, ServiceReference, dict, bool) -> None """ Calls back component binding and field binding methods when the properties of an injected dependency have been updated. ...
python
def __update_binding( self, dependency, service, reference, old_properties, new_value ): # type: (Any, Any, ServiceReference, dict, bool) -> None """ Calls back component binding and field binding methods when the properties of an injected dependency have been updated. ...
[ "def", "__update_binding", "(", "self", ",", "dependency", ",", "service", ",", "reference", ",", "old_properties", ",", "new_value", ")", ":", "# type: (Any, Any, ServiceReference, dict, bool) -> None", "if", "new_value", ":", "# Set the value", "setattr", "(", "self",...
Calls back component binding and field binding methods when the properties of an injected dependency have been updated. :param dependency: The dependency handler :param service: The injected service :param reference: The reference of the injected service :param old_properties: P...
[ "Calls", "back", "component", "binding", "and", "field", "binding", "methods", "when", "the", "properties", "of", "an", "injected", "dependency", "have", "been", "updated", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L894-L925
tcalmant/ipopo
pelix/ipopo/instance.py
StoredInstance.__unset_binding
def __unset_binding(self, dependency, service, reference): # type: (Any, Any, ServiceReference) -> None """ Removes a service from the component :param dependency: The dependency handler :param service: The injected service :param reference: The reference of the injected...
python
def __unset_binding(self, dependency, service, reference): # type: (Any, Any, ServiceReference) -> None """ Removes a service from the component :param dependency: The dependency handler :param service: The injected service :param reference: The reference of the injected...
[ "def", "__unset_binding", "(", "self", ",", "dependency", ",", "service", ",", "reference", ")", ":", "# type: (Any, Any, ServiceReference) -> None", "# Call the component back", "self", ".", "__safe_field_callback", "(", "dependency", ".", "get_field", "(", ")", ",", ...
Removes a service from the component :param dependency: The dependency handler :param service: The injected service :param reference: The reference of the injected service
[ "Removes", "a", "service", "from", "the", "component" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L927-L950
tcalmant/ipopo
pelix/misc/eventadmin_printer.py
_parse_boolean
def _parse_boolean(value): """ Returns a boolean value corresponding to the given value. :param value: Any value :return: Its boolean value """ if not value: return False try: # Lower string to check known "false" value value = value.lower() return value not...
python
def _parse_boolean(value): """ Returns a boolean value corresponding to the given value. :param value: Any value :return: Its boolean value """ if not value: return False try: # Lower string to check known "false" value value = value.lower() return value not...
[ "def", "_parse_boolean", "(", "value", ")", ":", "if", "not", "value", ":", "return", "False", "try", ":", "# Lower string to check known \"false\" value", "value", "=", "value", ".", "lower", "(", ")", "return", "value", "not", "in", "(", "\"none\"", ",", "...
Returns a boolean value corresponding to the given value. :param value: Any value :return: Its boolean value
[ "Returns", "a", "boolean", "value", "corresponding", "to", "the", "given", "value", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/misc/eventadmin_printer.py#L58-L74
tcalmant/ipopo
pelix/ipopo/handlers/requiresvarfilter.py
_VariableFilterMixIn._find_keys
def _find_keys(self): """ Looks for the property keys in the filter string :return: A list of property keys """ formatter = string.Formatter() return [ val[1] for val in formatter.parse(self._original_filter) if val[1] ]
python
def _find_keys(self): """ Looks for the property keys in the filter string :return: A list of property keys """ formatter = string.Formatter() return [ val[1] for val in formatter.parse(self._original_filter) if val[1] ]
[ "def", "_find_keys", "(", "self", ")", ":", "formatter", "=", "string", ".", "Formatter", "(", ")", "return", "[", "val", "[", "1", "]", "for", "val", "in", "formatter", ".", "parse", "(", "self", ".", "_original_filter", ")", "if", "val", "[", "1", ...
Looks for the property keys in the filter string :return: A list of property keys
[ "Looks", "for", "the", "property", "keys", "in", "the", "filter", "string" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/handlers/requiresvarfilter.py#L162-L171
tcalmant/ipopo
pelix/ipopo/handlers/requiresvarfilter.py
_VariableFilterMixIn.update_filter
def update_filter(self): """ Update the filter according to the new properties :return: True if the filter changed, else False :raise ValueError: The filter is invalid """ # Consider the filter invalid self.valid_filter = False try: # Format ...
python
def update_filter(self): """ Update the filter according to the new properties :return: True if the filter changed, else False :raise ValueError: The filter is invalid """ # Consider the filter invalid self.valid_filter = False try: # Format ...
[ "def", "update_filter", "(", "self", ")", ":", "# Consider the filter invalid", "self", ".", "valid_filter", "=", "False", "try", ":", "# Format the new filter", "filter_str", "=", "self", ".", "_original_filter", ".", "format", "(", "*", "*", "self", ".", "_com...
Update the filter according to the new properties :return: True if the filter changed, else False :raise ValueError: The filter is invalid
[ "Update", "the", "filter", "according", "to", "the", "new", "properties" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/handlers/requiresvarfilter.py#L173-L210
tcalmant/ipopo
pelix/ipopo/handlers/requiresvarfilter.py
_VariableFilterMixIn.on_property_change
def on_property_change(self, name, old_value, new_value): # pylint: disable=W0613 """ A component property has been updated :param name: Name of the property :param old_value: Previous value of the property :param new_value: New value of the property """ ...
python
def on_property_change(self, name, old_value, new_value): # pylint: disable=W0613 """ A component property has been updated :param name: Name of the property :param old_value: Previous value of the property :param new_value: New value of the property """ ...
[ "def", "on_property_change", "(", "self", ",", "name", ",", "old_value", ",", "new_value", ")", ":", "# pylint: disable=W0613", "if", "name", "in", "self", ".", "_keys", ":", "try", ":", "if", "self", ".", "update_filter", "(", ")", ":", "# This is a key for...
A component property has been updated :param name: Name of the property :param old_value: Previous value of the property :param new_value: New value of the property
[ "A", "component", "property", "has", "been", "updated" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/handlers/requiresvarfilter.py#L212-L231
tcalmant/ipopo
pelix/ipopo/handlers/requiresvarfilter.py
_VariableFilterMixIn._reset
def _reset(self): """ Called when the filter has been changed """ with self._lock: # Start listening to services with the new filter self.stop() self.start() for svc_ref in self.get_bindings(): # Check if the current refere...
python
def _reset(self): """ Called when the filter has been changed """ with self._lock: # Start listening to services with the new filter self.stop() self.start() for svc_ref in self.get_bindings(): # Check if the current refere...
[ "def", "_reset", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "# Start listening to services with the new filter", "self", ".", "stop", "(", ")", "self", ".", "start", "(", ")", "for", "svc_ref", "in", "self", ".", "get_bindings", "(", ")", ":...
Called when the filter has been changed
[ "Called", "when", "the", "filter", "has", "been", "changed" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/handlers/requiresvarfilter.py#L233-L249
tcalmant/ipopo
pelix/threadpool.py
EventData.set
def set(self, data=None): """ Sets the event """ self.__data = data self.__exception = None self.__event.set()
python
def set(self, data=None): """ Sets the event """ self.__data = data self.__exception = None self.__event.set()
[ "def", "set", "(", "self", ",", "data", "=", "None", ")", ":", "self", ".", "__data", "=", "data", "self", ".", "__exception", "=", "None", "self", ".", "__event", ".", "set", "(", ")" ]
Sets the event
[ "Sets", "the", "event" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/threadpool.py#L97-L103
tcalmant/ipopo
pelix/threadpool.py
EventData.raise_exception
def raise_exception(self, exception): """ Raises an exception in wait() :param exception: An Exception object """ self.__data = None self.__exception = exception self.__event.set()
python
def raise_exception(self, exception): """ Raises an exception in wait() :param exception: An Exception object """ self.__data = None self.__exception = exception self.__event.set()
[ "def", "raise_exception", "(", "self", ",", "exception", ")", ":", "self", ".", "__data", "=", "None", "self", ".", "__exception", "=", "exception", "self", ".", "__event", ".", "set", "(", ")" ]
Raises an exception in wait() :param exception: An Exception object
[ "Raises", "an", "exception", "in", "wait", "()" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/threadpool.py#L105-L113
tcalmant/ipopo
pelix/threadpool.py
EventData.wait
def wait(self, timeout=None): """ Waits for the event or for the timeout :param timeout: Wait timeout (in seconds) :return: True if the event as been set, else False """ # The 'or' part is for Python 2.6 result = self.__event.wait(timeout) # pylint: disab...
python
def wait(self, timeout=None): """ Waits for the event or for the timeout :param timeout: Wait timeout (in seconds) :return: True if the event as been set, else False """ # The 'or' part is for Python 2.6 result = self.__event.wait(timeout) # pylint: disab...
[ "def", "wait", "(", "self", ",", "timeout", "=", "None", ")", ":", "# The 'or' part is for Python 2.6", "result", "=", "self", ".", "__event", ".", "wait", "(", "timeout", ")", "# pylint: disable=E0702", "# Pylint seems to miss the \"is None\" check below", "if", "sel...
Waits for the event or for the timeout :param timeout: Wait timeout (in seconds) :return: True if the event as been set, else False
[ "Waits", "for", "the", "event", "or", "for", "the", "timeout" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/threadpool.py#L115-L129
tcalmant/ipopo
pelix/threadpool.py
FutureResult.__notify
def __notify(self): """ Notify the given callback about the result of the execution """ if self.__callback is not None: try: self.__callback( self._done_event.data, self._done_event.exception, self.__...
python
def __notify(self): """ Notify the given callback about the result of the execution """ if self.__callback is not None: try: self.__callback( self._done_event.data, self._done_event.exception, self.__...
[ "def", "__notify", "(", "self", ")", ":", "if", "self", ".", "__callback", "is", "not", "None", ":", "try", ":", "self", ".", "__callback", "(", "self", ".", "_done_event", ".", "data", ",", "self", ".", "_done_event", ".", "exception", ",", "self", ...
Notify the given callback about the result of the execution
[ "Notify", "the", "given", "callback", "about", "the", "result", "of", "the", "execution" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/threadpool.py#L153-L165
tcalmant/ipopo
pelix/threadpool.py
FutureResult.set_callback
def set_callback(self, method, extra=None): """ Sets a callback method, called once the result has been computed or in case of exception. The callback method must have the following signature: ``callback(result, exception, extra)``. :param method: The method to call bac...
python
def set_callback(self, method, extra=None): """ Sets a callback method, called once the result has been computed or in case of exception. The callback method must have the following signature: ``callback(result, exception, extra)``. :param method: The method to call bac...
[ "def", "set_callback", "(", "self", ",", "method", ",", "extra", "=", "None", ")", ":", "self", ".", "__callback", "=", "method", "self", ".", "__extra", "=", "extra", "if", "self", ".", "_done_event", ".", "is_set", "(", ")", ":", "# The execution has a...
Sets a callback method, called once the result has been computed or in case of exception. The callback method must have the following signature: ``callback(result, exception, extra)``. :param method: The method to call back in the end of the execution :param extra: Extra parame...
[ "Sets", "a", "callback", "method", "called", "once", "the", "result", "has", "been", "computed", "or", "in", "case", "of", "exception", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/threadpool.py#L167-L182
tcalmant/ipopo
pelix/threadpool.py
FutureResult.execute
def execute(self, method, args, kwargs): """ Execute the given method and stores its result. The result is considered "done" even if the method raises an exception :param method: The method to execute :param args: Method positional arguments :param kwargs: Method keyword...
python
def execute(self, method, args, kwargs): """ Execute the given method and stores its result. The result is considered "done" even if the method raises an exception :param method: The method to execute :param args: Method positional arguments :param kwargs: Method keyword...
[ "def", "execute", "(", "self", ",", "method", ",", "args", ",", "kwargs", ")", ":", "# Normalize arguments", "if", "args", "is", "None", ":", "args", "=", "[", "]", "if", "kwargs", "is", "None", ":", "kwargs", "=", "{", "}", "try", ":", "# Call the m...
Execute the given method and stores its result. The result is considered "done" even if the method raises an exception :param method: The method to execute :param args: Method positional arguments :param kwargs: Method keyword arguments :raise Exception: The exception raised by ...
[ "Execute", "the", "given", "method", "and", "stores", "its", "result", ".", "The", "result", "is", "considered", "done", "even", "if", "the", "method", "raises", "an", "exception" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/threadpool.py#L184-L213
tcalmant/ipopo
pelix/threadpool.py
FutureResult.result
def result(self, timeout=None): """ Waits up to timeout for the result the threaded job. Returns immediately the result if the job has already been done. :param timeout: The maximum time to wait for a result (in seconds) :raise OSError: The timeout raised before the job finished...
python
def result(self, timeout=None): """ Waits up to timeout for the result the threaded job. Returns immediately the result if the job has already been done. :param timeout: The maximum time to wait for a result (in seconds) :raise OSError: The timeout raised before the job finished...
[ "def", "result", "(", "self", ",", "timeout", "=", "None", ")", ":", "if", "self", ".", "_done_event", ".", "wait", "(", "timeout", ")", ":", "return", "self", ".", "_done_event", ".", "data", "else", ":", "raise", "OSError", "(", "\"Timeout raised\"", ...
Waits up to timeout for the result the threaded job. Returns immediately the result if the job has already been done. :param timeout: The maximum time to wait for a result (in seconds) :raise OSError: The timeout raised before the job finished :raise Exception: The exception encountered...
[ "Waits", "up", "to", "timeout", "for", "the", "result", "the", "threaded", "job", ".", "Returns", "immediately", "the", "result", "if", "the", "job", "has", "already", "been", "done", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/threadpool.py#L221-L233
tcalmant/ipopo
pelix/threadpool.py
ThreadPool.start
def start(self): """ Starts the thread pool. Does nothing if the pool is already started. """ if not self._done_event.is_set(): # Stop event not set: we're running return # Clear the stop event self._done_event.clear() # Compute the numbe...
python
def start(self): """ Starts the thread pool. Does nothing if the pool is already started. """ if not self._done_event.is_set(): # Stop event not set: we're running return # Clear the stop event self._done_event.clear() # Compute the numbe...
[ "def", "start", "(", "self", ")", ":", "if", "not", "self", ".", "_done_event", ".", "is_set", "(", ")", ":", "# Stop event not set: we're running", "return", "# Clear the stop event", "self", ".", "_done_event", ".", "clear", "(", ")", "# Compute the number of th...
Starts the thread pool. Does nothing if the pool is already started.
[ "Starts", "the", "thread", "pool", ".", "Does", "nothing", "if", "the", "pool", "is", "already", "started", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/threadpool.py#L308-L334
tcalmant/ipopo
pelix/threadpool.py
ThreadPool.__start_thread
def __start_thread(self): """ Starts a new thread, if possible """ with self.__lock: if self.__nb_threads >= self._max_threads: # Can't create more threads return False if self._done_event.is_set(): # We're stopped:...
python
def __start_thread(self): """ Starts a new thread, if possible """ with self.__lock: if self.__nb_threads >= self._max_threads: # Can't create more threads return False if self._done_event.is_set(): # We're stopped:...
[ "def", "__start_thread", "(", "self", ")", ":", "with", "self", ".", "__lock", ":", "if", "self", ".", "__nb_threads", ">=", "self", ".", "_max_threads", ":", "# Can't create more threads", "return", "False", "if", "self", ".", "_done_event", ".", "is_set", ...
Starts a new thread, if possible
[ "Starts", "a", "new", "thread", "if", "possible" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/threadpool.py#L336-L362
tcalmant/ipopo
pelix/threadpool.py
ThreadPool.stop
def stop(self): """ Stops the thread pool. Does nothing if the pool is already stopped. """ if self._done_event.is_set(): # Stop event set: we're stopped return # Set the stop event self._done_event.set() with self.__lock: # A...
python
def stop(self): """ Stops the thread pool. Does nothing if the pool is already stopped. """ if self._done_event.is_set(): # Stop event set: we're stopped return # Set the stop event self._done_event.set() with self.__lock: # A...
[ "def", "stop", "(", "self", ")", ":", "if", "self", ".", "_done_event", ".", "is_set", "(", ")", ":", "# Stop event set: we're stopped", "return", "# Set the stop event", "self", ".", "_done_event", ".", "set", "(", ")", "with", "self", ".", "__lock", ":", ...
Stops the thread pool. Does nothing if the pool is already stopped.
[ "Stops", "the", "thread", "pool", ".", "Does", "nothing", "if", "the", "pool", "is", "already", "stopped", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/threadpool.py#L364-L400
tcalmant/ipopo
pelix/threadpool.py
ThreadPool.enqueue
def enqueue(self, method, *args, **kwargs): """ Queues a task in the pool :param method: Method to call :return: A FutureResult object, to get the result of the task :raise ValueError: Invalid method :raise Full: The task queue is full """ if not hasattr(...
python
def enqueue(self, method, *args, **kwargs): """ Queues a task in the pool :param method: Method to call :return: A FutureResult object, to get the result of the task :raise ValueError: Invalid method :raise Full: The task queue is full """ if not hasattr(...
[ "def", "enqueue", "(", "self", ",", "method", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "hasattr", "(", "method", ",", "\"__call__\"", ")", ":", "raise", "ValueError", "(", "\"{0} has no __call__ member.\"", ".", "format", "(", "m...
Queues a task in the pool :param method: Method to call :return: A FutureResult object, to get the result of the task :raise ValueError: Invalid method :raise Full: The task queue is full
[ "Queues", "a", "task", "in", "the", "pool" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/threadpool.py#L402-L429
tcalmant/ipopo
pelix/threadpool.py
ThreadPool.clear
def clear(self): """ Empties the current queue content. Returns once the queue have been emptied. """ with self.__lock: # Empty the current queue try: while True: self._queue.get_nowait() self._queue....
python
def clear(self): """ Empties the current queue content. Returns once the queue have been emptied. """ with self.__lock: # Empty the current queue try: while True: self._queue.get_nowait() self._queue....
[ "def", "clear", "(", "self", ")", ":", "with", "self", ".", "__lock", ":", "# Empty the current queue", "try", ":", "while", "True", ":", "self", ".", "_queue", ".", "get_nowait", "(", ")", "self", ".", "_queue", ".", "task_done", "(", ")", "except", "...
Empties the current queue content. Returns once the queue have been emptied.
[ "Empties", "the", "current", "queue", "content", ".", "Returns", "once", "the", "queue", "have", "been", "emptied", "." ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/threadpool.py#L431-L447
tcalmant/ipopo
pelix/threadpool.py
ThreadPool.join
def join(self, timeout=None): """ Waits for all the tasks to be executed :param timeout: Maximum time to wait (in seconds) :return: True if the queue has been emptied, else False """ if self._queue.empty(): # Nothing to wait for... return True ...
python
def join(self, timeout=None): """ Waits for all the tasks to be executed :param timeout: Maximum time to wait (in seconds) :return: True if the queue has been emptied, else False """ if self._queue.empty(): # Nothing to wait for... return True ...
[ "def", "join", "(", "self", ",", "timeout", "=", "None", ")", ":", "if", "self", ".", "_queue", ".", "empty", "(", ")", ":", "# Nothing to wait for...", "return", "True", "elif", "timeout", "is", "None", ":", "# Use the original join", "self", ".", "_queue...
Waits for all the tasks to be executed :param timeout: Maximum time to wait (in seconds) :return: True if the queue has been emptied, else False
[ "Waits", "for", "all", "the", "tasks", "to", "be", "executed" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/threadpool.py#L449-L467
tcalmant/ipopo
pelix/threadpool.py
ThreadPool.__run
def __run(self): """ The main loop """ already_cleaned = False try: while not self._done_event.is_set(): try: # Wait for an action (blocking) task = self._queue.get(True, self._timeout) if tas...
python
def __run(self): """ The main loop """ already_cleaned = False try: while not self._done_event.is_set(): try: # Wait for an action (blocking) task = self._queue.get(True, self._timeout) if tas...
[ "def", "__run", "(", "self", ")", ":", "already_cleaned", "=", "False", "try", ":", "while", "not", "self", ".", "_done_event", ".", "is_set", "(", ")", ":", "try", ":", "# Wait for an action (blocking)", "task", "=", "self", ".", "_queue", ".", "get", "...
The main loop
[ "The", "main", "loop" ]
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/threadpool.py#L469-L534
cfhamlet/os-docid
src/os_docid/x.py
docid
def docid(url, encoding='ascii'): """Get DocID from URL. DocID generation depends on bytes of the URL string. So, if non-ascii charactors in the URL, encoding should be considered properly. Args: url (str or bytes): Pre-encoded bytes or string will be encoded with the 'encoding...
python
def docid(url, encoding='ascii'): """Get DocID from URL. DocID generation depends on bytes of the URL string. So, if non-ascii charactors in the URL, encoding should be considered properly. Args: url (str or bytes): Pre-encoded bytes or string will be encoded with the 'encoding...
[ "def", "docid", "(", "url", ",", "encoding", "=", "'ascii'", ")", ":", "if", "not", "isinstance", "(", "url", ",", "bytes", ")", ":", "url", "=", "url", ".", "encode", "(", "encoding", ")", "parser", "=", "_URL_PARSER", "idx", "=", "0", "for", "_c"...
Get DocID from URL. DocID generation depends on bytes of the URL string. So, if non-ascii charactors in the URL, encoding should be considered properly. Args: url (str or bytes): Pre-encoded bytes or string will be encoded with the 'encoding' argument. encoding (str, option...
[ "Get", "DocID", "from", "URL", "." ]
train
https://github.com/cfhamlet/os-docid/blob/d3730aa118182f903b540ea738cd47c83f6b5e89/src/os_docid/x.py#L172-L229
hasgeek/coaster
coaster/logger.py
init_app
def init_app(app): """ Enables logging for an app using :class:`LocalVarFormatter`. Requires the app to be configured and checks for the following configuration parameters. All are optional: * ``LOGFILE``: Name of the file to log to (default ``error.log``) * ``ADMINS``: List of email addresses ...
python
def init_app(app): """ Enables logging for an app using :class:`LocalVarFormatter`. Requires the app to be configured and checks for the following configuration parameters. All are optional: * ``LOGFILE``: Name of the file to log to (default ``error.log``) * ``ADMINS``: List of email addresses ...
[ "def", "init_app", "(", "app", ")", ":", "formatter", "=", "LocalVarFormatter", "(", ")", "error_log_file", "=", "app", ".", "config", ".", "get", "(", "'LOGFILE'", ",", "'error.log'", ")", "if", "error_log_file", ":", "# Specify a falsy value in config to disable...
Enables logging for an app using :class:`LocalVarFormatter`. Requires the app to be configured and checks for the following configuration parameters. All are optional: * ``LOGFILE``: Name of the file to log to (default ``error.log``) * ``ADMINS``: List of email addresses of admins who will be mailed er...
[ "Enables", "logging", "for", "an", "app", "using", ":", "class", ":", "LocalVarFormatter", ".", "Requires", "the", "app", "to", "be", "configured", "and", "checks", "for", "the", "following", "configuration", "parameters", ".", "All", "are", "optional", ":" ]
train
https://github.com/hasgeek/coaster/blob/07f7eb5d5f516e22fa14fdf4dc70e0ae13ee398d/coaster/logger.py#L246-L329
hasgeek/coaster
coaster/logger.py
LocalVarFormatter.format
def format(self, record): """ Format the specified record as text. Overrides :meth:`logging.Formatter.format` to remove cache of :attr:`record.exc_text` unless it was produced by this formatter. """ if record.exc_info: if record.exc_text: if "S...
python
def format(self, record): """ Format the specified record as text. Overrides :meth:`logging.Formatter.format` to remove cache of :attr:`record.exc_text` unless it was produced by this formatter. """ if record.exc_info: if record.exc_text: if "S...
[ "def", "format", "(", "self", ",", "record", ")", ":", "if", "record", ".", "exc_info", ":", "if", "record", ".", "exc_text", ":", "if", "\"Stack frames (most recent call first)\"", "not", "in", "record", ".", "exc_text", ":", "record", ".", "exc_text", "=",...
Format the specified record as text. Overrides :meth:`logging.Formatter.format` to remove cache of :attr:`record.exc_text` unless it was produced by this formatter.
[ "Format", "the", "specified", "record", "as", "text", ".", "Overrides", ":", "meth", ":", "logging", ".", "Formatter", ".", "format", "to", "remove", "cache", "of", ":", "attr", ":", "record", ".", "exc_text", "unless", "it", "was", "produced", "by", "th...
train
https://github.com/hasgeek/coaster/blob/07f7eb5d5f516e22fa14fdf4dc70e0ae13ee398d/coaster/logger.py#L40-L50
hasgeek/coaster
coaster/utils/text.py
sanitize_html
def sanitize_html(value, valid_tags=VALID_TAGS, strip=True): """ Strips unwanted markup out of HTML. """ return bleach.clean(value, tags=list(VALID_TAGS.keys()), attributes=VALID_TAGS, strip=strip)
python
def sanitize_html(value, valid_tags=VALID_TAGS, strip=True): """ Strips unwanted markup out of HTML. """ return bleach.clean(value, tags=list(VALID_TAGS.keys()), attributes=VALID_TAGS, strip=strip)
[ "def", "sanitize_html", "(", "value", ",", "valid_tags", "=", "VALID_TAGS", ",", "strip", "=", "True", ")", ":", "return", "bleach", ".", "clean", "(", "value", ",", "tags", "=", "list", "(", "VALID_TAGS", ".", "keys", "(", ")", ")", ",", "attributes",...
Strips unwanted markup out of HTML.
[ "Strips", "unwanted", "markup", "out", "of", "HTML", "." ]
train
https://github.com/hasgeek/coaster/blob/07f7eb5d5f516e22fa14fdf4dc70e0ae13ee398d/coaster/utils/text.py#L61-L65
hasgeek/coaster
coaster/utils/text.py
word_count
def word_count(text, html=True): """ Return the count of words in the given text. If the text is HTML (default True), tags are stripped before counting. Handles punctuation and bad formatting like.this when counting words, but assumes conventions for Latin script languages. May not be reliable for o...
python
def word_count(text, html=True): """ Return the count of words in the given text. If the text is HTML (default True), tags are stripped before counting. Handles punctuation and bad formatting like.this when counting words, but assumes conventions for Latin script languages. May not be reliable for o...
[ "def", "word_count", "(", "text", ",", "html", "=", "True", ")", ":", "if", "html", ":", "text", "=", "_tag_re", ".", "sub", "(", "' '", ",", "text", ")", "text", "=", "_strip_re", ".", "sub", "(", "''", ",", "text", ")", "text", "=", "_punctuati...
Return the count of words in the given text. If the text is HTML (default True), tags are stripped before counting. Handles punctuation and bad formatting like.this when counting words, but assumes conventions for Latin script languages. May not be reliable for other languages.
[ "Return", "the", "count", "of", "words", "in", "the", "given", "text", ".", "If", "the", "text", "is", "HTML", "(", "default", "True", ")", "tags", "are", "stripped", "before", "counting", ".", "Handles", "punctuation", "and", "bad", "formatting", "like", ...
train
https://github.com/hasgeek/coaster/blob/07f7eb5d5f516e22fa14fdf4dc70e0ae13ee398d/coaster/utils/text.py#L138-L149
hasgeek/coaster
coaster/utils/text.py
deobfuscate_email
def deobfuscate_email(text): """ Deobfuscate email addresses in provided text """ text = unescape(text) # Find the "dot" text = _deobfuscate_dot1_re.sub('.', text) text = _deobfuscate_dot2_re.sub(r'\1.\2', text) text = _deobfuscate_dot3_re.sub(r'\1.\2', text) # Find the "at" text...
python
def deobfuscate_email(text): """ Deobfuscate email addresses in provided text """ text = unescape(text) # Find the "dot" text = _deobfuscate_dot1_re.sub('.', text) text = _deobfuscate_dot2_re.sub(r'\1.\2', text) text = _deobfuscate_dot3_re.sub(r'\1.\2', text) # Find the "at" text...
[ "def", "deobfuscate_email", "(", "text", ")", ":", "text", "=", "unescape", "(", "text", ")", "# Find the \"dot\"", "text", "=", "_deobfuscate_dot1_re", ".", "sub", "(", "'.'", ",", "text", ")", "text", "=", "_deobfuscate_dot2_re", ".", "sub", "(", "r'\\1.\\...
Deobfuscate email addresses in provided text
[ "Deobfuscate", "email", "addresses", "in", "provided", "text" ]
train
https://github.com/hasgeek/coaster/blob/07f7eb5d5f516e22fa14fdf4dc70e0ae13ee398d/coaster/utils/text.py#L161-L175
hasgeek/coaster
coaster/utils/text.py
simplify_text
def simplify_text(text): """ Simplify text to allow comparison. >>> simplify_text("Awesome Coder wanted at Awesome Company") 'awesome coder wanted at awesome company' >>> simplify_text("Awesome Coder, wanted at Awesome Company! ") 'awesome coder wanted at awesome company' >>> simplify_text...
python
def simplify_text(text): """ Simplify text to allow comparison. >>> simplify_text("Awesome Coder wanted at Awesome Company") 'awesome coder wanted at awesome company' >>> simplify_text("Awesome Coder, wanted at Awesome Company! ") 'awesome coder wanted at awesome company' >>> simplify_text...
[ "def", "simplify_text", "(", "text", ")", ":", "if", "isinstance", "(", "text", ",", "six", ".", "text_type", ")", ":", "if", "six", ".", "PY3", ":", "# pragma: no cover", "text", "=", "text", ".", "translate", "(", "text", ".", "maketrans", "(", "\"\"...
Simplify text to allow comparison. >>> simplify_text("Awesome Coder wanted at Awesome Company") 'awesome coder wanted at awesome company' >>> simplify_text("Awesome Coder, wanted at Awesome Company! ") 'awesome coder wanted at awesome company' >>> simplify_text(u"Awesome Coder, wanted at Awesome ...
[ "Simplify", "text", "to", "allow", "comparison", "." ]
train
https://github.com/hasgeek/coaster/blob/07f7eb5d5f516e22fa14fdf4dc70e0ae13ee398d/coaster/utils/text.py#L178-L196
hasgeek/coaster
coaster/nlp.py
extract_named_entities
def extract_named_entities(text_blocks): """ Return a list of named entities extracted from provided text blocks (list of text strings). """ sentences = [] for text in text_blocks: sentences.extend(nltk.sent_tokenize(text)) tokenized_sentences = [nltk.word_tokenize(sentence) for sentenc...
python
def extract_named_entities(text_blocks): """ Return a list of named entities extracted from provided text blocks (list of text strings). """ sentences = [] for text in text_blocks: sentences.extend(nltk.sent_tokenize(text)) tokenized_sentences = [nltk.word_tokenize(sentence) for sentenc...
[ "def", "extract_named_entities", "(", "text_blocks", ")", ":", "sentences", "=", "[", "]", "for", "text", "in", "text_blocks", ":", "sentences", ".", "extend", "(", "nltk", ".", "sent_tokenize", "(", "text", ")", ")", "tokenized_sentences", "=", "[", "nltk",...
Return a list of named entities extracted from provided text blocks (list of text strings).
[ "Return", "a", "list", "of", "named", "entities", "extracted", "from", "provided", "text", "blocks", "(", "list", "of", "text", "strings", ")", "." ]
train
https://github.com/hasgeek/coaster/blob/07f7eb5d5f516e22fa14fdf4dc70e0ae13ee398d/coaster/nlp.py#L20-L48
hasgeek/coaster
coaster/manage.py
set_alembic_revision
def set_alembic_revision(path=None): """Create/Update alembic table to latest revision number""" config = Config() try: config.set_main_option("script_location", path or "migrations") script = ScriptDirectory.from_config(config) head = script.get_current_head() # create alemb...
python
def set_alembic_revision(path=None): """Create/Update alembic table to latest revision number""" config = Config() try: config.set_main_option("script_location", path or "migrations") script = ScriptDirectory.from_config(config) head = script.get_current_head() # create alemb...
[ "def", "set_alembic_revision", "(", "path", "=", "None", ")", ":", "config", "=", "Config", "(", ")", "try", ":", "config", ".", "set_main_option", "(", "\"script_location\"", ",", "path", "or", "\"migrations\"", ")", "script", "=", "ScriptDirectory", ".", "...
Create/Update alembic table to latest revision number
[ "Create", "/", "Update", "alembic", "table", "to", "latest", "revision", "number" ]
train
https://github.com/hasgeek/coaster/blob/07f7eb5d5f516e22fa14fdf4dc70e0ae13ee398d/coaster/manage.py#L54-L75
hasgeek/coaster
coaster/manage.py
dropdb
def dropdb(): """Drop database tables""" manager.db.engine.echo = True if prompt_bool("Are you sure you want to lose all your data"): manager.db.drop_all() metadata, alembic_version = alembic_table_metadata() alembic_version.drop() manager.db.session.commit()
python
def dropdb(): """Drop database tables""" manager.db.engine.echo = True if prompt_bool("Are you sure you want to lose all your data"): manager.db.drop_all() metadata, alembic_version = alembic_table_metadata() alembic_version.drop() manager.db.session.commit()
[ "def", "dropdb", "(", ")", ":", "manager", ".", "db", ".", "engine", ".", "echo", "=", "True", "if", "prompt_bool", "(", "\"Are you sure you want to lose all your data\"", ")", ":", "manager", ".", "db", ".", "drop_all", "(", ")", "metadata", ",", "alembic_v...
Drop database tables
[ "Drop", "database", "tables" ]
train
https://github.com/hasgeek/coaster/blob/07f7eb5d5f516e22fa14fdf4dc70e0ae13ee398d/coaster/manage.py#L79-L86
hasgeek/coaster
coaster/manage.py
createdb
def createdb(): """Create database tables from sqlalchemy models""" manager.db.engine.echo = True manager.db.create_all() set_alembic_revision()
python
def createdb(): """Create database tables from sqlalchemy models""" manager.db.engine.echo = True manager.db.create_all() set_alembic_revision()
[ "def", "createdb", "(", ")", ":", "manager", ".", "db", ".", "engine", ".", "echo", "=", "True", "manager", ".", "db", ".", "create_all", "(", ")", "set_alembic_revision", "(", ")" ]
Create database tables from sqlalchemy models
[ "Create", "database", "tables", "from", "sqlalchemy", "models" ]
train
https://github.com/hasgeek/coaster/blob/07f7eb5d5f516e22fa14fdf4dc70e0ae13ee398d/coaster/manage.py#L90-L94
hasgeek/coaster
coaster/manage.py
sync_resources
def sync_resources(): """Sync the client's resources with the Lastuser server""" print("Syncing resources with Lastuser...") resources = manager.app.lastuser.sync_resources()['results'] for rname, resource in six.iteritems(resources): if resource['status'] == 'error': print("Error f...
python
def sync_resources(): """Sync the client's resources with the Lastuser server""" print("Syncing resources with Lastuser...") resources = manager.app.lastuser.sync_resources()['results'] for rname, resource in six.iteritems(resources): if resource['status'] == 'error': print("Error f...
[ "def", "sync_resources", "(", ")", ":", "print", "(", "\"Syncing resources with Lastuser...\"", ")", "resources", "=", "manager", ".", "app", ".", "lastuser", ".", "sync_resources", "(", ")", "[", "'results'", "]", "for", "rname", ",", "resource", "in", "six",...
Sync the client's resources with the Lastuser server
[ "Sync", "the", "client", "s", "resources", "with", "the", "Lastuser", "server" ]
train
https://github.com/hasgeek/coaster/blob/07f7eb5d5f516e22fa14fdf4dc70e0ae13ee398d/coaster/manage.py#L98-L113
hasgeek/coaster
coaster/manage.py
init_manager
def init_manager(app, db, **kwargs): """ Initialise Manager :param app: Flask app object :parm db: db instance :param kwargs: Additional keyword arguments to be made available as shell context """ manager.app = app manager.db = db manager.context = kwargs manager.add_command('db...
python
def init_manager(app, db, **kwargs): """ Initialise Manager :param app: Flask app object :parm db: db instance :param kwargs: Additional keyword arguments to be made available as shell context """ manager.app = app manager.db = db manager.context = kwargs manager.add_command('db...
[ "def", "init_manager", "(", "app", ",", "db", ",", "*", "*", "kwargs", ")", ":", "manager", ".", "app", "=", "app", "manager", ".", "db", "=", "db", "manager", ".", "context", "=", "kwargs", "manager", ".", "add_command", "(", "'db'", ",", "MigrateCo...
Initialise Manager :param app: Flask app object :parm db: db instance :param kwargs: Additional keyword arguments to be made available as shell context
[ "Initialise", "Manager" ]
train
https://github.com/hasgeek/coaster/blob/07f7eb5d5f516e22fa14fdf4dc70e0ae13ee398d/coaster/manage.py#L122-L139