_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q9500
BundleCompleter.complete
train
def complete( self, config, prompt, session, context, current_arguments, current ): # type: (CompletionInfo, str, ShellSession, BundleContext, List[str], str) -> List[str] """ Returns the list of bundle IDs matching the current state :param config: Configuration of the curre...
python
{ "resource": "" }
q9501
Container.is_valid
train
def is_valid(self): # type: () -> bool """ Checks if the component is valid :return: Always True if it doesn't raise an exception :raises AssertionError: Invalid properties """ assert self._bundle_context assert self._container_props is not None a...
python
{ "resource": "" }
q9502
Container._add_export
train
def _add_export(self, ed_id, inst): # type: (str, Tuple[Any, EndpointDescription]) -> None """ Keeps track of an exported service :param ed_id: ID of the endpoint description :param inst: A tuple: (service instance, endpoint description) """ with self._exported_i...
python
{ "resource": "" }
q9503
Container._find_export
train
def _find_export(self, func): # type: (Callable[[Tuple[Any, EndpointDescription]], bool]) -> Optional[Tuple[Any, EndpointDescription]] """ Look for an export using the given lookup method The lookup method must accept a single parameter, which is a tuple containing a service ins...
python
{ "resource": "" }
q9504
ExportContainer._export_service
train
def _export_service(self, svc, ed): # type: (Any, EndpointDescription) -> None """ Registers a service export :param svc: Service instance :param ed: Endpoint description """ self._add_export(ed.get_id(), (svc, ed))
python
{ "resource": "" }
q9505
ExportContainer.prepare_endpoint_props
train
def prepare_endpoint_props(self, intfs, svc_ref, export_props): # type: (List[str], ServiceReference, Dict[str, Any]) -> Dict[str, Any] """ Sets up the properties of an endpoint :param intfs: Specifications to export :param svc_ref: Reference of the exported service :par...
python
{ "resource": "" }
q9506
ExportContainer.export_service
train
def export_service(self, svc_ref, export_props): # type: (ServiceReference, Dict[str, Any]) -> EndpointDescription """ Exports the given service :param svc_ref: Reference to the service to export :param export_props: Export properties :return: The endpoint description ...
python
{ "resource": "" }
q9507
_FactoryCounter.get_service
train
def get_service(self, factory, svc_registration): # type: (Any, ServiceRegistration) -> Any """ Returns the service required by the bundle. The Service Factory is called only when necessary while the Prototype Service Factory is called each time :param factory: The servi...
python
{ "resource": "" }
q9508
_FactoryCounter.unget_service
train
def unget_service(self, factory, svc_registration, service=None): # type: (Any, ServiceRegistration, Any) -> bool """ Releases references to the given service reference :param factory: The service factory :param svc_registration: The ServiceRegistration object :param ser...
python
{ "resource": "" }
q9509
_FactoryCounter.cleanup_service
train
def cleanup_service(self, factory, svc_registration): # type: (Any, ServiceRegistration) -> bool """ If this bundle used that factory, releases the reference; else does nothing :param factory: The service factory :param svc_registration: The ServiceRegistration object ...
python
{ "resource": "" }
q9510
ServiceReference.unused_by
train
def unused_by(self, bundle): """ Indicates that this reference is not being used anymore by the given bundle. This method should only be used by the framework. :param bundle: A bundle that used this reference """ if bundle is None or bundle is self.__bundle: ...
python
{ "resource": "" }
q9511
ServiceReference.used_by
train
def used_by(self, bundle): """ Indicates that this reference is being used by the given bundle. This method should only be used by the framework. :param bundle: A bundle using this reference """ if bundle is None or bundle is self.__bundle: # Ignore ...
python
{ "resource": "" }
q9512
ServiceRegistration.set_properties
train
def set_properties(self, properties): """ Updates the service properties :param properties: The new properties :raise TypeError: The argument is not a dictionary """ if not isinstance(properties, dict): raise TypeError("Waiting for dictionary") # Key...
python
{ "resource": "" }
q9513
EventDispatcher.clear
train
def clear(self): """ Clears the event dispatcher """ with self.__bnd_lock: self.__bnd_listeners = [] with self.__svc_lock: self.__svc_listeners.clear() with self.__fw_lock: self.__fw_listeners = []
python
{ "resource": "" }
q9514
EventDispatcher.add_bundle_listener
train
def add_bundle_listener(self, listener): """ Adds a bundle listener :param listener: The bundle listener to register :return: True if the listener has been registered, False if it was already known :raise BundleException: An invalid listener has been given ...
python
{ "resource": "" }
q9515
EventDispatcher.add_framework_listener
train
def add_framework_listener(self, listener): """ Registers a listener that will be called back right before the framework stops. :param listener: The framework stop listener :return: True if the listener has been registered, False if it was already known ...
python
{ "resource": "" }
q9516
EventDispatcher.remove_bundle_listener
train
def remove_bundle_listener(self, listener): """ Unregisters a bundle listener :param listener: The bundle listener to unregister :return: True if the listener has been unregistered, else False """ with self.__bnd_lock: if listener not in self.__bnd_listeners:...
python
{ "resource": "" }
q9517
EventDispatcher.remove_framework_listener
train
def remove_framework_listener(self, listener): """ Unregisters a framework stop listener :param listener: The framework listener to unregister :return: True if the listener has been unregistered, else False """ with self.__fw_lock: try: self._...
python
{ "resource": "" }
q9518
EventDispatcher.remove_service_listener
train
def remove_service_listener(self, listener): """ Unregisters a service listener :param listener: The service listener :return: True if the listener has been unregistered """ with self.__svc_lock: try: data = self.__listeners_data.pop(listener)...
python
{ "resource": "" }
q9519
EventDispatcher.fire_bundle_event
train
def fire_bundle_event(self, event): """ Notifies bundle events listeners of a new event in the calling thread. :param event: The bundle event """ with self.__bnd_lock: # Copy the list of listeners listeners = self.__bnd_listeners[:] # Call'em all...
python
{ "resource": "" }
q9520
EventDispatcher.fire_framework_stopping
train
def fire_framework_stopping(self): """ Calls all framework listeners, telling them that the framework is stopping """ with self.__fw_lock: # Copy the list of listeners listeners = self.__fw_listeners[:] for listener in listeners: try: ...
python
{ "resource": "" }
q9521
EventDispatcher.fire_service_event
train
def fire_service_event(self, event): """ Notifies service events listeners of a new event in the calling thread. :param event: The service event """ # Get the service properties properties = event.get_service_reference().get_properties() svc_specs = properties[OB...
python
{ "resource": "" }
q9522
EventDispatcher._filter_with_hooks
train
def _filter_with_hooks(self, svc_event, listeners): """ Filters listeners with EventListenerHooks :param svc_event: ServiceEvent being triggered :param listeners: Listeners to filter :return: A list of listeners with hook references """ svc_ref = svc_event.get_se...
python
{ "resource": "" }
q9523
ServiceRegistry.clear
train
def clear(self): """ Clears the registry """ with self.__svc_lock: self.__svc_registry.clear() self.__svc_factories.clear() self.__svc_specs.clear() self.__bundle_svc.clear() self.__bundle_imports.clear() self.__fact...
python
{ "resource": "" }
q9524
ServiceRegistry.__sort_registry
train
def __sort_registry(self, svc_ref): # type: (ServiceReference) -> None """ Sorts the registry, after the update of the sort key of given service reference :param svc_ref: A service reference with a modified sort key """ with self.__svc_lock: if svc_re...
python
{ "resource": "" }
q9525
ServiceRegistry.unregister
train
def unregister(self, svc_ref): # type: (ServiceReference) -> Any """ Unregisters a service :param svc_ref: A service reference :return: The unregistered service instance :raise BundleException: Unknown service reference """ with self.__svc_lock: ...
python
{ "resource": "" }
q9526
ServiceRegistry.get_bundle_imported_services
train
def get_bundle_imported_services(self, bundle): """ Returns this bundle's ServiceReference list for all services it is using or returns None if this bundle is not using any services. A bundle is considered to be using a service if its use count for that service is greater than ze...
python
{ "resource": "" }
q9527
ServiceRegistry.get_bundle_registered_services
train
def get_bundle_registered_services(self, bundle): # type: (Any) -> List[ServiceReference] """ Retrieves the services registered by the given bundle. Returns None if the bundle didn't register any service. :param bundle: The bundle to look into :return: The references to ...
python
{ "resource": "" }
q9528
ServiceRegistry.__get_service_from_factory
train
def __get_service_from_factory(self, bundle, reference): # type: (Any, ServiceReference) -> Any """ Returns a service instance from a service factory or a prototype service factory :param bundle: The bundle requiring the service :param reference: A reference pointing to ...
python
{ "resource": "" }
q9529
ServiceRegistry.unget_used_services
train
def unget_used_services(self, bundle): """ Cleans up all service usages of the given bundle. :param bundle: Bundle to be cleaned up """ # Pop used references try: imported_refs = list(self.__bundle_imports.pop(bundle)) except KeyError: # N...
python
{ "resource": "" }
q9530
ServiceRegistry.unget_service
train
def unget_service(self, bundle, reference, service=None): # type: (Any, ServiceReference, Any) -> bool """ Removes the usage of a service by a bundle :param bundle: The bundle that used the service :param reference: A service reference :param service: Service instance (f...
python
{ "resource": "" }
q9531
ServiceRegistry.__unget_service_from_factory
train
def __unget_service_from_factory(self, bundle, reference, service=None): # type: (Any, ServiceReference, Any) -> bool """ Removes the usage of a a service factory or a prototype service factory by a bundle :param bundle: The bundle that used the service :param reference:...
python
{ "resource": "" }
q9532
EDEFReader._convert_value
train
def _convert_value(vtype, value): """ Converts the given value string according to the given type :param vtype: Type of the value :param value: String form of the value :return: The converted value :raise ValueError: Conversion failed """ # Normalize valu...
python
{ "resource": "" }
q9533
EDEFWriter._indent
train
def _indent(self, element, level=0, prefix="\t"): """ In-place Element text auto-indent, for pretty printing. Code from: http://effbot.org/zone/element-lib.htm#prettyprint :param element: An Element object :param level: Level of indentation :param prefix: String to use ...
python
{ "resource": "" }
q9534
EDEFWriter._add_container
train
def _add_container(props_node, tag, container): """ Walks through the given container and fills the node :param props_node: A property node :param tag: Name of the container tag :param container: The container """ values_node = ElementTree.SubElement(props_node, ...
python
{ "resource": "" }
q9535
EDEFWriter._get_type
train
def _get_type(name, value): """ Returns the type associated to the given name or value :param name: Property name :param value: Property value :return: A value type name """ # Types forced for known keys if name in TYPED_BOOL: return TYPE_BOOL...
python
{ "resource": "" }
q9536
BasicBot.on_session_start
train
def on_session_start(self, data): # pylint: disable=W0613 """ XMPP session started """ # Send initial presence self.send_presence(ppriority=self._initial_priority) # Request roster self.get_roster()
python
{ "resource": "" }
q9537
InviteMixIn.on_invite
train
def on_invite(self, data): """ Multi-User Chat invite """ if not self._nick: self._nick = self.boundjid.user # Join the room self.plugin["xep_0045"].joinMUC(data["from"], self._nick)
python
{ "resource": "" }
q9538
ServiceDiscoveryMixin.iter_services
train
def iter_services(self, feature=None): """ Iterates over the root-level services on the server which provides the requested feature :param feature: Feature that the service must provide (optional) :return: A generator of services JID """ # Get the list of root se...
python
{ "resource": "" }
q9539
_find_assignment
train
def _find_assignment(arg_token): """ Find the first non-escaped assignment in the given argument token. Returns -1 if no assignment was found. :param arg_token: The argument token :return: The index of the first assignment, or -1 """ idx = arg_token.find("=") while idx != -1: if...
python
{ "resource": "" }
q9540
_split_ns_command
train
def _split_ns_command(cmd_token): """ Extracts the name space and the command name of the given command token. :param cmd_token: The command token :return: The extracted (name space, command) tuple """ namespace = None cmd_split = cmd_token.split(".", 1) if len(cmd_split) == 1: ...
python
{ "resource": "" }
q9541
Shell.register_command
train
def register_command(self, namespace, command, method): """ Registers the given command to the shell. The namespace can be None, empty or "default" :param namespace: The command name space. :param command: The shell name of the command :param method: The method to call ...
python
{ "resource": "" }
q9542
Shell.get_command_completers
train
def get_command_completers(self, namespace, command): # type: (str, str) -> CompletionInfo """ Returns the completer method associated to the given command, or None :param namespace: The command name space. :param command: The shell name of the command :return: A Complet...
python
{ "resource": "" }
q9543
Shell.unregister
train
def unregister(self, namespace, command=None): """ Unregisters the given command. If command is None, the whole name space is unregistered. :param namespace: The command name space. :param command: The shell name of the command, or None :return: True if the command was k...
python
{ "resource": "" }
q9544
Shell.__find_command_ns
train
def __find_command_ns(self, command): """ Returns the name spaces where the given command named is registered. If the command exists in the default name space, the returned list will only contain the default name space. Returns an empty list of the command is unknown :pa...
python
{ "resource": "" }
q9545
Shell.get_ns_commands
train
def get_ns_commands(self, cmd_name): """ Retrieves the possible name spaces and commands associated to the given command name. :param cmd_name: The given command name :return: A list of 2-tuples (name space, command) :raise ValueError: Unknown command name """ ...
python
{ "resource": "" }
q9546
Shell.get_ns_command
train
def get_ns_command(self, cmd_name): """ Retrieves the name space and the command associated to the given command name. :param cmd_name: The given command name :return: A 2-tuple (name space, command) :raise ValueError: Unknown command name """ namespace, ...
python
{ "resource": "" }
q9547
Shell.execute
train
def execute(self, cmdline, session=None): """ Executes the command corresponding to the given line :param cmdline: Command line to parse :param session: Current shell session :return: True if command succeeded, else False """ if session is None: # Def...
python
{ "resource": "" }
q9548
Shell.__extract_help
train
def __extract_help(method): """ Formats the help string for the given method :param method: The method to document :return: A tuple: (arguments list, documentation line) """ if method is None: return "(No associated method)" # Get the arguments ...
python
{ "resource": "" }
q9549
Shell.__print_command_help
train
def __print_command_help(self, session, namespace, cmd_name): """ Prints the documentation of the given command :param session: Session handler :param namespace: Name space of the command :param cmd_name: Name of the command """ # Extract documentation ar...
python
{ "resource": "" }
q9550
Shell.__print_namespace_help
train
def __print_namespace_help(self, session, namespace, cmd_name=None): """ Prints the documentation of all the commands in the given name space, or only of the given command :param session: Session Handler :param namespace: Name space of the command :param cmd_name: Name o...
python
{ "resource": "" }
q9551
Shell.print_help
train
def print_help(self, session, command=None): """ Prints the available methods and their documentation, or the documentation of the given command. """ if command: # Single command mode if command in self._commands: # Argument is a name space...
python
{ "resource": "" }
q9552
Shell.var_unset
train
def var_unset(session, name): """ Unsets the given variable """ name = name.strip() try: session.unset(name) except KeyError: session.write_line("Unknown variable: {0}", name) return False else: session.write_line("V...
python
{ "resource": "" }
q9553
_Configuration.add_properties
train
def add_properties(self, properties): """ Updates the framework properties dictionary :param properties: New framework properties to add """ if isinstance(properties, dict): self._properties.update(properties)
python
{ "resource": "" }
q9554
_Configuration.add_environment
train
def add_environment(self, environ): """ Updates the environment dictionary with the given one. Existing entries are overridden by the given ones :param environ: New environment variables """ if isinstance(environ, dict): self._environment.update(environ)
python
{ "resource": "" }
q9555
_Configuration.add_paths
train
def add_paths(self, paths): """ Adds entries to the Python path. The given paths are normalized before being added to the left of the list :param paths: New paths to add """ if paths: # Use new paths in priority self._paths = list(paths) ...
python
{ "resource": "" }
q9556
_Configuration.add_components
train
def add_components(self, components): """ Adds a list of components to instantiate :param components: The description of components :raise KeyError: Missing component configuration """ if components: for component in components: self._componen...
python
{ "resource": "" }
q9557
_Configuration.normalize
train
def normalize(self): """ Normalizes environment variables, paths and filters the lists of bundles to install and start. After this call, the environment variables of this process will have been updated. """ # Add environment variables os.environ.update(se...
python
{ "resource": "" }
q9558
InitFileHandler.find_default
train
def find_default(self, filename): """ A generate which looks in common folders for the default configuration file. The paths goes from system defaults to user specific files. :param filename: The name of the file to find :return: The complete path to the found files """ ...
python
{ "resource": "" }
q9559
InitFileHandler.load
train
def load(self, filename=None): """ Loads the given file and adds its content to the current state. This method can be called multiple times to merge different files. If no filename is given, this method loads all default files found. It returns False if no default configuration ...
python
{ "resource": "" }
q9560
InitFileHandler.__parse
train
def __parse(self, configuration): """ Parses the given configuration dictionary :param configuration: A configuration as a dictionary (JSON object) """ for entry in ( "properties", "environment", "paths", "bundles", "co...
python
{ "resource": "" }
q9561
InitFileHandler.normalize
train
def normalize(self): """ Normalizes environment variables and the Python path. This method first updates the environment variables (``os.environ``). Then, it normalizes the Python path (``sys.path``) by resolving all references to the user directory and environment variables. ...
python
{ "resource": "" }
q9562
InitFileHandler.instantiate_components
train
def instantiate_components(self, context): """ Instantiate the defined components .. note:: This method requires the iPOPO core service to be registered. This means that the ``pelix.ipopo.core`` must have been declared in the list of bundles (or installed and st...
python
{ "resource": "" }
q9563
literalize_string
train
def literalize_string(content, is_unicode=False): r'''Literalize a string content. Examples: >>> print literalize_string('str') 'str' >>> print literalize_string('\'str\'') "'str'" >>> print literalize_string('\"\'str\'\"') '"\'str\'"' ''' quote_mark = "'" if "'" in conten...
python
{ "resource": "" }
q9564
unescape_string_literal
train
def unescape_string_literal(literal, encoding): r'''Unescape a string or unicode literal. Examples: >>> u = u'\u4e16\u754c\u4f60\u597d' # 世界你好 >>> print unescape_string_literal(repr(u), 'utf-8') u'世界你好' >>> print unescape_string_literal(repr(u.encode('utf-8')), 'utf-8') '世界你好' >>> pr...
python
{ "resource": "" }
q9565
unescape
train
def unescape(b, encoding): '''Unescape all string and unicode literals in bytes.''' return string_literal_re.sub( lambda m: unescape_string_literal(m.group(), encoding), b )
python
{ "resource": "" }
q9566
make_unistream
train
def make_unistream(stream): '''Make a stream which unescapes string literals before writes out.''' unistream = lambda: 'I am an unistream!' # make unistream look like the stream for attr_name in dir(stream): if not attr_name.startswith('_'): setattr(unistream, attr_name, getattr(st...
python
{ "resource": "" }
q9567
format_frame_info
train
def format_frame_info(frame): """ Formats the given stack frame to show its position in the code and part of its context :param frame: A stack frame """ # Same as in traceback.extract_stack line_no = frame.f_lineno code = frame.f_code filename = code.co_filename method_name = co...
python
{ "resource": "" }
q9568
_extract_lines
train
def _extract_lines(filename, f_globals, line_no, around): """ Extracts a block of lines from the given file :param filename: Name of the source file :param f_globals: Globals of the frame of the current code :param line_no: Current line of code :param around: Number of line to print before and ...
python
{ "resource": "" }
q9569
_ReportCommands.get_level_methods
train
def get_level_methods(self, level): """ Returns the methods to call for the given level of report :param level: The level of report :return: The set of methods to call to fill the report :raise KeyError: Unknown level or alias """ try: # Real name of ...
python
{ "resource": "" }
q9570
_ReportCommands.print_levels
train
def print_levels(self, session): """ Lists available levels """ lines = [] for level in sorted(self.get_levels()): methods = sorted( method.__name__ for method in self.get_level_methods(level) ) lines.append("- {0}:".format(leve...
python
{ "resource": "" }
q9571
_ReportCommands.os_details
train
def os_details(): """ Returns a dictionary containing details about the operating system """ # Compute architecture and linkage bits, linkage = platform.architecture() results = { # Machine details "platform.arch.bits": bits, "platform....
python
{ "resource": "" }
q9572
_ReportCommands.process_details
train
def process_details(): """ Returns details about the current process """ results = {"argv": sys.argv, "working.directory": os.getcwd()} # Process ID and execution IDs (UID, GID, Login, ...) for key, method in { "pid": "getpid", "ppid": "getppid", ...
python
{ "resource": "" }
q9573
_ReportCommands.network_details
train
def network_details(): """ Returns details about the network links """ # Get IPv4 details ipv4_addresses = [ info[4][0] for info in socket.getaddrinfo( socket.gethostname(), None, socket.AF_INET ) ] # Add localh...
python
{ "resource": "" }
q9574
_ReportCommands.python_details
train
def python_details(): """ Returns a dictionary containing details about the Python interpreter """ build_no, build_date = platform.python_build() results = { # Version of interpreter "build.number": build_no, "build.date": build_date, ...
python
{ "resource": "" }
q9575
_ReportCommands.python_modules
train
def python_modules(): """ Returns the list of Python modules and their file """ imported = {} results = {"builtins": sys.builtin_module_names, "imported": imported} for module_name, module_ in sys.modules.items(): if module_name not in sys.builtin_module_names...
python
{ "resource": "" }
q9576
_ReportCommands.pelix_infos
train
def pelix_infos(self): """ Basic information about the Pelix framework instance """ framework = self.__context.get_framework() return { "version": framework.get_version(), "properties": framework.get_properties(), }
python
{ "resource": "" }
q9577
_ReportCommands.pelix_bundles
train
def pelix_bundles(self): """ List of installed bundles """ framework = self.__context.get_framework() return { bundle.get_bundle_id(): { "name": bundle.get_symbolic_name(), "version": bundle.get_version(), "state": bundl...
python
{ "resource": "" }
q9578
_ReportCommands.pelix_services
train
def pelix_services(self): """ List of registered services """ return { svc_ref.get_property(pelix.constants.SERVICE_ID): { "specifications": svc_ref.get_property( pelix.constants.OBJECTCLASS ), "ranking": svc...
python
{ "resource": "" }
q9579
_ReportCommands.ipopo_factories
train
def ipopo_factories(self): """ List of iPOPO factories """ try: with use_ipopo(self.__context) as ipopo: return { name: ipopo.get_factory_details(name) for name in ipopo.get_factories() } except B...
python
{ "resource": "" }
q9580
_ReportCommands.ipopo_instances
train
def ipopo_instances(self): """ List of iPOPO instances """ try: with use_ipopo(self.__context) as ipopo: return { instance[0]: ipopo.get_instance_details(instance[0]) for instance in ipopo.get_instances() ...
python
{ "resource": "" }
q9581
_ReportCommands.to_json
train
def to_json(self, data): """ Converts the given object to a pretty-formatted JSON string :param data: the object to convert to JSON :return: A pretty-formatted JSON string """ # Don't forget the empty line at the end of the file return ( json.dumps( ...
python
{ "resource": "" }
q9582
_ReportCommands.show_report
train
def show_report(self, session, *levels): """ Shows the report that has been generated """ if levels: self.make_report(session, *levels) if self.__report: session.write_line(self.to_json(self.__report)) else: session.write_line("No repo...
python
{ "resource": "" }
q9583
_ReportCommands.write_report
train
def write_report(self, session, filename): """ Writes the report in JSON format to the given file """ if not self.__report: session.write_line("No report to write down") return try: with open(filename, "w+") as out_file: out_fi...
python
{ "resource": "" }
q9584
_MqttCallableProxy.handle_result
train
def handle_result(self, result, error): """ The result has been received :param result: Call result :param error: Error message """ if not self._error and not self._result: # Store results, if not already set self._error = error self._...
python
{ "resource": "" }
q9585
main
train
def main(): """ Starts a Pelix framework and waits for it to stop """ # Prepare the framework, with iPOPO and the shell console # Warning: we only use the first argument of this method, a list of bundles framework = pelix.framework.create_framework(( # iPOPO "pelix.ipopo.core", ...
python
{ "resource": "" }
q9586
wrap_socket
train
def wrap_socket(socket, certfile, keyfile, password=None): """ Wraps an existing TCP socket and returns an SSLSocket object :param socket: The socket to wrap :param certfile: The server certificate file :param keyfile: The server private key file :param password: Password for the private key fi...
python
{ "resource": "" }
q9587
make_html_list
train
def make_html_list(items, tag="ul"): # type: (Iterable[Any], str) -> str """ Makes a HTML list from the given iterable :param items: The items to list :param tag: The tag to use (ul or ol) :return: The HTML list code """ html_list = "\n".join( '<li><a href="{0}">{0}</a></li>'.fo...
python
{ "resource": "" }
q9588
AbstractHTTPServletRequest.read_data
train
def read_data(self): # type: () -> ByteString """ Reads all the data in the input stream :return: The read data """ try: size = int(self.get_header("content-length")) except (ValueError, TypeError): size = -1 return self.get_rfile...
python
{ "resource": "" }
q9589
AbstractHTTPServletResponse.send_content
train
def send_content( self, http_code, content, mime_type="text/html", http_message=None, content_length=-1, ): # type: (int, str, str, str, int) -> None """ Utility method to send the given content as an answer. You can still use get_wfile...
python
{ "resource": "" }
q9590
make_mreq
train
def make_mreq(family, address): """ Makes a mreq structure object for the given address and socket family. :param family: A socket family (AF_INET or AF_INET6) :param address: A multicast address (group) :raise ValueError: Invalid family or address """ if not address: raise ValueErr...
python
{ "resource": "" }
q9591
create_multicast_socket
train
def create_multicast_socket(address, port): """ Creates a multicast socket according to the given address and port. Handles both IPv4 and IPv6 addresses. :param address: Multicast address/group :param port: Socket port :return: A tuple (socket, listening address) :raise ValueError: Invalid ...
python
{ "resource": "" }
q9592
close_multicast_socket
train
def close_multicast_socket(sock, address): """ Cleans up the given multicast socket. Unregisters it of the multicast group. Parameters should be the result of create_multicast_socket :param sock: A multicast socket :param address: The multicast address used by the socket """ if sock is...
python
{ "resource": "" }
q9593
HelloImpl.sayHello
train
def sayHello(self, name="Not given", message="nothing"): """ Synchronous implementation of IHello.sayHello synchronous method. The remote calling thread will be blocked until this is executed and responds. """ print( "Python.sayHello called by: {0} " ...
python
{ "resource": "" }
q9594
HelloImpl.sayHelloPromise
train
def sayHelloPromise(self, name="Not given", message="nothing"): """ Implementation of IHello.sayHelloPromise. This method will be executed via some thread, and the remote caller will not block. """ print( "Python.sayHelloPromise called by: {0} " "w...
python
{ "resource": "" }
q9595
_set_factory_context
train
def _set_factory_context(factory_class, bundle_context): # type: (type, Optional[BundleContext]) -> Optional[FactoryContext] """ Transforms the context data dictionary into its FactoryContext object form. :param factory_class: A manipulated class :param bundle_context: The class bundle context ...
python
{ "resource": "" }
q9596
_IPopoService.__find_handler_factories
train
def __find_handler_factories(self): """ Finds all registered handler factories and stores them """ # Get the references svc_refs = self.__context.get_all_service_references( handlers_const.SERVICE_IPOPO_HANDLER_FACTORY ) if svc_refs: for sv...
python
{ "resource": "" }
q9597
_IPopoService.__add_handler_factory
train
def __add_handler_factory(self, svc_ref): # type: (ServiceReference) -> None """ Stores a new handler factory :param svc_ref: ServiceReference of the new handler factory """ with self.__handlers_lock: # Get the handler ID handler_id = svc_ref.get_...
python
{ "resource": "" }
q9598
_IPopoService.__remove_handler_factory
train
def __remove_handler_factory(self, svc_ref): # type: (ServiceReference) -> None """ Removes an handler factory :param svc_ref: ServiceReference of the handler factory to remove """ with self.__handlers_lock: # Get the handler ID handler_id = svc_r...
python
{ "resource": "" }
q9599
_IPopoService.__get_factory_with_context
train
def __get_factory_with_context(self, factory_name): # type: (str) -> Tuple[type, FactoryContext] """ Retrieves the factory registered with the given and its factory context :param factory_name: The name of the factory :return: A (factory, context) tuple :raise TypeError:...
python
{ "resource": "" }