Base Component Classes¶
When you write your own plugins, you have to extend one of those classes.
Base component¶
- class pyf.componentized.components.Component¶
- Configuration available :
- “advanced” (label: Advanced): Compound key (each sub key is an individual tag)
- “separate_process” (label: Separate Process): boolean
- “name” (label: Name): Simple key/value (text-based)
unique name
- get_config_key(key, default=None)¶
Returns a config key for the current process and id or default value. If the configuration protocol is defined, it will return a fully formatted value. Else, it will return the node content text.
- set_config_key(key, value)¶
Sets a config key for the current process and id. WARNING: Dangerous, shouldn’t be used.
Base code component¶
When you create a node from code (for prototyping), the manager automatically generates a CodeComponent :
- class pyf.componentized.components.CodeComponent(config_node, name, gets_data=True)¶
When you create a node from code (not from plugin: code adapters, code producers, code consumers), a CodeComponent is instanced.
- There is three types of code blocks :
- function (default value, and forced for producers):
Your code is executed and imported like an external module.
- Instructions for your code :
The last function of your code is called.
- Your function should have:
- no argument if it’s a producer,
- an iterator as argument if it’s an adapter or a consumer.
You function should be a generator, yielding items or statuses (True if ok / False if error) if it’s a consumer.
- Variables magically accessible:
- message_callback (function): a function taking a message as an unicode string, that will be passed to the message dispatching system (ex. in pyf.services it will be shown in the event track).
- progression_callback (function, only for producers): a function taking an integer or a decimal.Decimal that will update the progress of the process.
- get_config_key (function): gets the value of the configuration node specified as first argument (second argument is the default value).
- exec:
Your code is executed before yielding the item. You can modify the “item” variable as you like (usefull for adapters). Accessible variable :
- item: the item entering your adapter.
- eval (only for adapters):
Will yield the result of the eval. Accessible variable :
- item: the item entering your adapter.
- Configuration available :
- “advanced” (label: Advanced): Compound key (each sub key is an individual tag)
- “separate_process” (label: Separate Process): boolean
- “name” (label: Name): Simple key/value (text-based)
unique name
- introspect_function()¶
Gets the name of the last element of the code block. This is used to get the name of the function to execute.
Base adapter¶
- class pyf.componentized.components.BaseAdapter(config_node, name)¶
- Configuration available :
- “advanced” (label: Advanced): Compound key (each sub key is an individual tag)
- “separate_process” (label: Separate Process): boolean
- “name” (label: Name): Simple key/value (text-based)
unique name
Base producer¶
- class pyf.componentized.components.Producer(config_node, name)¶
- Configuration available :
- “advanced” (label: Advanced): Compound key (each sub key is an individual tag)
- “separate_process” (label: Separate Process): boolean
- “name” (label: Name): Simple key/value (text-based)
unique name
Base consumer¶
The base consumer is just a base component with nothing added.
Base Writer¶
- class pyf.componentized.components.writer.Writer¶
- Configuration available :
- “advanced” (label: Advanced): Compound key (each sub key is an individual tag)
- “separate_process” (label: Separate Process): boolean
- “name” (label: Name): Simple key/value (text-based)
unique name
File Writer¶
- class pyf.componentized.components.FileWriter(config_node, name, target_filename)¶
- Configuration available :
- “advanced” (label: Advanced): Compound key (each sub key is an individual tag)
- “separate_process” (label: Separate Process): boolean
- “name” (label: Name): Simple key/value (text-based)
unique name
“encoding” (label: Encoding): Simple key/value (text-based) (default: “UTF-8”)
“target_filename” (label: Target filename): Simple key/value (text-based)
Multiple File Writer¶
- class pyf.componentized.components.multiwriter.MultipleFileWriter(config_node, name)¶
- Configuration available :
- “advanced” (label: Advanced): Compound key (each sub key is an individual tag)
- “separate_process” (label: Separate Process): boolean
- “name” (label: Name): Simple key/value (text-based)
unique name
“encoding” (label: Encoding): Simple key/value (text-based) (default: “UTF-8”)
“target_filename” (label: Target filename): Simple key/value (text-based)
- “splitkey” (label: Split Attribute (optionnal)): Simple key/value (text-based)
Attribute with which to split files