module ipythonhelper.magic_class_crypt
¶
Short summary¶
module pyquickhelper.ipythonhelper.magic_class_crypt
Magic command to handle files
Classes¶
class |
truncated documentation |
---|---|
Defines magic commands to encrypt and decrypt file. |
Functions¶
function |
truncated documentation |
---|---|
Register magics function, can be called from a notebook. |
Properties¶
property |
truncated documentation |
---|---|
|
return the context or None |
|
A contextmanager for running a block with our cross validation lock set to True. At the end of the block, … |
Static Methods¶
staticmethod |
truncated documentation |
---|---|
defines the way to parse the magic command |
|
defines the way to parse the magic command |
|
defines the way to parse the magic command |
Methods¶
method |
truncated documentation |
---|---|
Documentation¶
Magic command to handle files
- class pyquickhelper.ipythonhelper.magic_class_crypt.MagicCrypt(**kwargs: Any)[source]¶
Bases:
MagicClassWithHelpers
Defines magic commands to encrypt and decrypt file.
Create a configurable given a config config.
Parameters¶
- configConfig
If this is empty, default values are used. If config is a
Config
instance, it will be used to configure the instance.- parentConfigurable instance, optional
The parent Configurable instance of this object.
Notes¶
Subclasses of Configurable must call the
__init__()
method ofConfigurable
before doing anything else and usingsuper()
:class MyConfigurable(Configurable): def __init__(self, config=None): super(MyConfigurable, self).__init__(config=config) # Then any other code you need to finish initialization.
This ensures that instances will be configured properly.
- _all_trait_default_generators: Dict[str, Any] = {'config': <bound method TraitType.default of <traitlets.traitlets.Instance object>>, 'parent': <bound method TraitType.default of <traitlets.traitlets.Instance object>>}[source]¶
- _descriptors = [<traitlets.traitlets.ObserveHandler object>, <traitlets.traitlets.Instance object>, <traitlets.traitlets.Instance object>][source]¶
- _instance_inits = [<bound method ObserveHandler.instance_init of <traitlets.traitlets.ObserveHandler object>>, <bound method Instance.instance_init of <traitlets.traitlets.Instance object>>, <bound method Instance.instance_init of <traitlets.traitlets.Instance object>>][source]¶
- _traits: Dict[str, Any] = {'config': <traitlets.traitlets.Instance object>, 'parent': <traitlets.traitlets.Instance object>}[source]¶
- decrypt_file(line)[source]¶
%decrypt_file
The magic command is equivalent to:
from pyquickhelper.filehelper import decrypt_stream password = "password" source = "file source" dest = "file destination" if isinstance(password, str): password = bytes(password, encoding="ascii") decrypt_stream(key=password, filename=source, out_filename=dest, chunksize=os.stat(source).st_size * 2 + 1)
- encrypt_file(line)[source]¶
%encrypt_file
The magic command is equivalent to:
from pyquickhelper.filehelper import encrypt_stream password = "password" source = "file source" dest = "file destination" if isinstance(password, str): password = bytes(password, encoding="ascii") encrypt_stream(key=password, filename=source, out_filename=dest, chunksize=os.stat(source).st_size * 2 + 1)