Glymur 0.13.6__py3-none-any.whl → 0.13.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
glymur/options.py CHANGED
@@ -1,4 +1,5 @@
1
1
  """Manage glymur configuration settings."""
2
+
2
3
  # Standard library imports
3
4
  import copy
4
5
  import warnings
@@ -9,11 +10,11 @@ from .lib import openjp2 as opj2
9
10
 
10
11
 
11
12
  _original_options = {
12
- 'lib.num_threads': 1,
13
- 'parse.full_codestream': False,
14
- 'print.xml': True,
15
- 'print.codestream': True,
16
- 'print.short': False,
13
+ "lib.num_threads": 1,
14
+ "parse.full_codestream": False,
15
+ "print.xml": True,
16
+ "print.codestream": True,
17
+ "print.short": False,
17
18
  }
18
19
  _options = copy.deepcopy(_original_options)
19
20
 
@@ -67,18 +68,18 @@ def set_option(key, value):
67
68
  get_option
68
69
  """
69
70
  if key not in _options.keys():
70
- raise KeyError(f'{key} not valid.')
71
+ raise KeyError(f"{key} not valid.")
71
72
 
72
- if key == 'lib.num_threads':
73
- if version.openjpeg_version < '2.2.0':
73
+ if key == "lib.num_threads":
74
+ if version.openjpeg_version < "2.2.0":
74
75
  msg = (
75
- f'Thread support is not available on versions of OpenJPEG '
76
- f'prior to 2.2.0. Your version is '
77
- f'{version.openjpeg_version}.'
76
+ f"Thread support is not available on versions of OpenJPEG "
77
+ f"prior to 2.2.0. Your version is "
78
+ f"{version.openjpeg_version}."
78
79
  )
79
80
  raise RuntimeError(msg)
80
81
  if not opj2.has_thread_support():
81
- msg = 'The OpenJPEG library is not configured with thread support.'
82
+ msg = "The OpenJPEG library is not configured with thread support."
82
83
  raise RuntimeError(msg)
83
84
 
84
85
  _options[key] = value
@@ -128,39 +129,43 @@ def reset_option(key):
128
129
  Name of a single option.
129
130
  """
130
131
  global _options
131
- if key == 'all':
132
+ if key == "all":
132
133
  _options = copy.deepcopy(_original_options)
133
134
  else:
134
135
  if key not in _options.keys():
135
- raise KeyError(f'{key} not valid.')
136
+ raise KeyError(f"{key} not valid.")
136
137
  _options[key] = _original_options[key]
137
138
 
138
139
 
139
140
  def set_parseoptions(full_codestream=True):
140
- warnings.warn('Use set_option instead of set_parseoptions.',
141
- DeprecationWarning)
142
- set_option('parse.full_codestream', full_codestream)
141
+ warnings.warn(
142
+ "Use set_option instead of set_parseoptions.", DeprecationWarning
143
+ )
144
+ set_option("parse.full_codestream", full_codestream)
143
145
 
144
146
 
145
147
  def get_parseoptions():
146
- warnings.warn('Use set_option instead of set_parseoptions.',
147
- DeprecationWarning)
148
- return {'full_codestream': get_option('parse.full_codestream')}
148
+ warnings.warn(
149
+ "Use set_option instead of set_parseoptions.", DeprecationWarning
150
+ )
151
+ return {"full_codestream": get_option("parse.full_codestream")}
149
152
 
150
153
 
151
154
  def set_printoptions(**kwargs):
152
- warnings.warn('Use set_option instead of set_printoptions.',
153
- DeprecationWarning)
155
+ warnings.warn(
156
+ "Use set_option instead of set_printoptions.", DeprecationWarning
157
+ )
154
158
  for key, value in kwargs.items():
155
- if key not in ['short', 'xml', 'codestream']:
159
+ if key not in ["short", "xml", "codestream"]:
156
160
  raise KeyError(f'"{key}" not a valid keyword parameter.')
157
- set_option('print.' + key, value)
161
+ set_option("print." + key, value)
158
162
 
159
163
 
160
164
  def get_printoptions():
161
- warnings.warn('Use get_option instead of get_printoptions.',
162
- DeprecationWarning)
165
+ warnings.warn(
166
+ "Use get_option instead of get_printoptions.", DeprecationWarning
167
+ )
163
168
  d = {}
164
- for key in ['short', 'xml', 'codestream']:
165
- d[key] = _options['print.' + key]
169
+ for key in ["short", "xml", "codestream"]:
170
+ d[key] = _options["print." + key]
166
171
  return d