Inherits from
- HasTraits: enthought.traits.has_traits.HasTraits
Attributes
- lines
The lines of code recorded.
lines = List(Str)
- recording
Are we recording or not?
recording = Bool(False, desc = 'if script recording is enabled or not')
- script
The Python script we have recorded so far. This is just a convenience trait for the get_code() method.
script = Property(Unicode)
Inherited from base classes
Method summary
- clear(self)
- get_code(self)
- get_object_path(self, object)
- get_script_id(self, object)
- is_registered(self, object)
- record(self, code)
- record_function(self, func, args, kw)
- register(self, object, parent = None, trait_name_on_parent = '', ignore = None, known = False, script_id = None)
- save(self, file)
- ui_save(self)
- unregister(self, object)
- write_script_id_in_namespace(self, script_id)
Inherited from base classes
- __deepcopy__(self, memo)
- __getstate__(self)
- __prefix_trait__(self, name, is_set)
- __reduce_ex__(self, protocol)
- __setstate__(self, state, trait_change_notify = True)
- add_class_trait(cls, name, *trait)
- add_trait(self, name, *trait)
- add_trait_category(cls, category)
- add_trait_listener(self, object, prefix = '')
- all_trait_names(self)
- base_trait(self, name)
- class_default_traits_view(cls)
- class_editable_traits(cls)
- class_trait_names(cls, **metadata)
- class_trait_view(cls, name = None, view_element = None)
- class_trait_view_elements(cls)
- class_traits(cls, **metadata)
- clone_traits(self, traits = None, memo = None, copy = None, **metadata)
- configure_traits(self, filename = None, view = None, kind = None, edit = True, context = None, handler = None, id = '', scrollable = None, **args)
- copy_traits(self, other, traits = None, memo = None, copy = None, **metadata)
- copyable_trait_names(self, **metadata)
- default_traits_view(self)
- edit_traits(self, view = None, parent = None, kind = None, context = None, handler = None, id = '', scrollable = None, **args)
- editable_traits(self)
- has_traits_interface(self, *interfaces)
- on_trait_change(self, handler, name = None, remove = False, dispatch = 'same', priority = False, deferred = False)
- print_traits(self, show_help = False, **metadata)
- remove_trait(self, name)
- remove_trait_listener(self, object, prefix = '')
- reset_traits(self, traits = None, **metadata)
- set_trait_dispatch_handler(cls, name, klass, override = False)
- sync_trait(self, trait_name, object, alias = None, mutual = True, remove = False)
- trait(self, name, force = False, copy = False)
- trait_context(self)
- trait_get(self, *names, **metadata)
- trait_monitor(cls, handler, remove = False)
- trait_names(self, **metadata)
- trait_set(self, trait_change_notify = True, **traits)
- trait_setq(self, **traits)
- trait_subclasses(cls, all = False)
- trait_view(self, name = None, view_element = None)
- trait_view_elements(self)
- trait_views(self, klass = None)
- traits(self, **metadata)
- validate_trait(self, name, value)
Methods
- clear(self)
Clears all previous recorded state and unregisters all registered objects.
- get_code(self)
Returns the recorded lines as a string of printable code.
- get_object_path(self, object)
Returns the path in the object hierarchy of a registered object. Useful for debugging.
- get_script_id(self, object)
Returns the script_id of a registered object. Useful when you want to manually add a record statement.
- is_registered(self, object)
Returns True if the given object is registered with the recorder.
- record(self, code)
Record a string to be stored to the output file.
Parameters:
code - A string of text.
- record_function(self, func, args, kw)
Record a function call given the function and its arguments.
- register(self, object, parent = None, trait_name_on_parent = '', ignore = None, known = False, script_id = None)
Register an object with the recorder. This sets up the object for recording.
By default all traits (except those starting and ending with '_') are recorded. For attributes that are themselves recordable, one may mark traits with a 'record' metadata as follows:
- If metadata record=False is set, the nested object will not be recorded.
- If record=True, then that object is also recorded if it is not None.
If the object is a list or dict that is marked with record=True, the list is itself not listened to for changes but all its contents are registered.
If the object has a trait named recorder then this recorder instance will be set to it if possible.
Parameters:
- object : Instance(HasTraits)
- The object to register in the registry.
- parent : Instance(HasTraits)
- An optional parent object in which object is contained
- trait_name_on_parent : str
- An optional trait name of the object in the parent.
- ignore : list(str)
- An optional list of trait names on the object to be ignored.
- known : bool
- Optional specification if the object id is known on the interpreter. This is needed if you are manually injecting code to define/create an object.
- script_id : str
- Optionally specify a script_id to use for this object. It is not guaranteed that this ID will be used since it may already be in use.
- save(self, file)
Save the recorded lines to the given file. It does not close the file.
- ui_save(self)
Save recording to file, pop up a UI dialog to find out where and close the file when done.
- unregister(self, object)
Unregister the given object from the recorder. This inverts the logic of the register(...) method.
- write_script_id_in_namespace(self, script_id)
If a script_id is not known in the current script's namespace, this sets it using the path of the object or actually instantiating it. If this is not possible (since the script_id matches no existing object), nothing is recorded but the framework is notified that the particular script_id is available in the namespace. This is useful when you want to inject code in the namespace to create a particular object.