Singleton object containing the current user defined configuration properties for orca. These parameters may optionally be saved to the user's ~/.plotly directory using the `save` method, in which case they are automatically restored in future sessions.
| 140 | # Orca configuration class |
| 141 | # ------------------------ |
| 142 | class OrcaConfig(object): |
| 143 | """ |
| 144 | Singleton object containing the current user defined configuration |
| 145 | properties for orca. |
| 146 | |
| 147 | These parameters may optionally be saved to the user's ~/.plotly |
| 148 | directory using the `save` method, in which case they are automatically |
| 149 | restored in future sessions. |
| 150 | """ |
| 151 | |
| 152 | def __init__(self): |
| 153 | # Initialize properties dict |
| 154 | self._props = {} |
| 155 | |
| 156 | # Compute absolute path to the 'plotly/package_data/' directory |
| 157 | root_dir = os.path.dirname(os.path.abspath(plotly.__file__)) |
| 158 | self.package_dir = os.path.join(root_dir, "package_data") |
| 159 | |
| 160 | # Load pre-existing configuration |
| 161 | self.reload(warn=False) |
| 162 | |
| 163 | # Compute constants |
| 164 | plotlyjs = os.path.join(self.package_dir, "plotly.min.js") |
| 165 | self._constants = { |
| 166 | "plotlyjs": plotlyjs, |
| 167 | "config_file": os.path.join(PLOTLY_DIR, ".orca"), |
| 168 | } |
| 169 | |
| 170 | def restore_defaults(self, reset_server=True): |
| 171 | """ |
| 172 | Reset all orca configuration properties to their default values |
| 173 | """ |
| 174 | self._props = {} |
| 175 | |
| 176 | if reset_server: |
| 177 | # Server must restart before setting is active |
| 178 | reset_status() |
| 179 | |
| 180 | def update(self, d={}, **kwargs): |
| 181 | """ |
| 182 | Update one or more properties from a dict or from input keyword |
| 183 | arguments. |
| 184 | |
| 185 | Parameters |
| 186 | ---------- |
| 187 | d: dict |
| 188 | Dictionary from property names to new property values. |
| 189 | |
| 190 | kwargs |
| 191 | Named argument value pairs where the name is a configuration |
| 192 | property name and the value is the new property value. |
| 193 | |
| 194 | Returns |
| 195 | ------- |
| 196 | None |
| 197 | |
| 198 | Examples |
| 199 | -------- |