| 1 |
"""Supported instruments and their properties for Argyll CMS. |
| 2 |
|
| 3 |
It provides utilities for managing instrument names, removing vendor prefixes, |
| 4 |
and mapping instrument names to canonical forms. |
| 5 |
""" |
| 6 |
|
| 7 |
from __future__ import annotations |
| 8 |
|
| 9 |
import re |
| 10 |
|
| 11 |
from DisplayCAL.util_str import strtr |
| 12 |
|
| 13 |
instruments = { |
| 14 |
# instrument names from Argyll source spectro/insttypes.c |
| 15 |
# |
| 16 |
# vid: USB Vendor ID |
| 17 |
# |
| 18 |
# pid: USB Product ID |
| 19 |
# |
| 20 |
# hid: Is the device a USB HID (Human Interface Device) class device? |
| 21 |
# |
| 22 |
# spectral: Does the instrument support spectral readings? |
| 23 |
# |
| 24 |
# adaptive_mode: Does the instrument support adaptive emissive readings? |
| 25 |
# |
| 26 |
# highres_mode: Does the instrument support high-res spectral readings? |
| 27 |
# |
| 28 |
# projector_mode: Does the instrument support a special projector mode? |
| 29 |
# |
| 30 |
# sensor_cal: Does the instrument need to calibrate its sensor by putting |
| 31 |
# it on a reference tile or black surface? |
| 32 |
# A value of False for sensor_cal means the instrument can be |
| 33 |
# left on the display |
| 34 |
# A value of True for sensor_cal means the instrument must be |
| 35 |
# removed from the display for sensor calibration if it cannot |
| 36 |
# be skipped |
| 37 |
# |
| 38 |
# skip_sensor_cal: Can the sensor calibration be skipped? |
| 39 |
# |
| 40 |
# integration_time: Approx. integration time (seconds) for black and white, |
| 41 |
# based on measurements on wide-gamut IPS display with |
| 42 |
# 0.23 cd/m2 black and 130 cd/m2 white level, rounded to |
| 43 |
# multiple of .1 seconds. |
| 44 |
# Instruments which I don't own have been estimated. |
| 45 |
# |
| 46 |
# refresh: Can the instrument do refresh rate measurements? |
| 47 |
# |
| 48 |
# spectral_cal: Does the instrument support spectral sample (CCSS) |
| 49 |
# calibration? |
| 50 |
# |
| 51 |
# A missing key, or a value of None, means unknown/not tested |
| 52 |
# |
| 53 |
# Instruments can have an id (short string) that is different than the |
| 54 |
# long instrument name. In case no id is given, the instrument name is |
| 55 |
# the same as the id. |
| 56 |
# TODO: Update instrument names from Argyll 2.3.0 |
| 57 |
"DTP92": { |
| 58 |
"usb_ids": [{"vid": 0x0765, "pid": 0xD092, "hid": False}], |
| 59 |
"spectral": False, |
| 60 |
"adaptive_mode": False, |
| 61 |
"highres_mode": False, |
| 62 |
"projector_mode": False, |
| 63 |
"sensor_cal": None, |
| 64 |
"skip_sensor_cal": None, |
| 65 |
"refresh": True, |
| 66 |
}, |
| 67 |
"DTP94": { |
| 68 |
"usb_ids": [{"vid": 0x0765, "pid": 0xD094, "hid": False}], |
| 69 |
"spectral": False, |
| 70 |
"adaptive_mode": False, |
| 71 |
"highres_mode": False, |
| 72 |
"projector_mode": False, |
| 73 |
"sensor_cal": False, |
| 74 |
"skip_sensor_cal": False, # DTP94 instrument access fails |
| 75 |
# when using -N option to skip automatic sensor calibration |
| 76 |
# (dispread -D9 output: "Setting no-sensor_calibrate failed |
| 77 |
# with 'Unsupported function'") |
| 78 |
"integration_time": [4.0, 1.1], # Estimated |
| 79 |
"refresh": True, |
| 80 |
}, |
| 81 |
"Spectrolino": { |
| 82 |
"spectral": True, |
| 83 |
"adaptive_mode": False, |
| 84 |
"highres_mode": False, |
| 85 |
"projector_mode": False, |
| 86 |
"sensor_cal": True, |
| 87 |
"skip_sensor_cal": True, |
| 88 |
}, |
| 89 |
"SpectroScan": { |
| 90 |
"spectral": True, |
| 91 |
"adaptive_mode": False, |
| 92 |
"highres_mode": False, |
| 93 |
"projector_mode": False, |
| 94 |
"sensor_cal": True, |
| 95 |
"skip_sensor_cal": True, |
| 96 |
}, |
| 97 |
"SpectroScanT": { |
| 98 |
"spectral": True, |
| 99 |
"adaptive_mode": False, |
| 100 |
"highres_mode": False, |
| 101 |
"projector_mode": False, |
| 102 |
"sensor_cal": True, |
| 103 |
"skip_sensor_cal": True, |
| 104 |
}, |
| 105 |
"Spectrocam": { |
| 106 |
"spectral": True, |
| 107 |
"adaptive_mode": False, |
| 108 |
"highres_mode": False, |
| 109 |
"projector_mode": False, |
| 110 |
"sensor_cal": True, |
| 111 |
"skip_sensor_cal": None, |
| 112 |
}, |
| 113 |
"i1 Display": { # Argyll 1.3.5 and earlier |
| 114 |
"usb_ids": [{"vid": 0x0670, "pid": 0x0001, "hid": False}], |
| 115 |
"id": "i1D1", |
| 116 |
"spectral": False, |
| 117 |
"adaptive_mode": False, |
| 118 |
"highres_mode": False, |
| 119 |
"projector_mode": False, |
| 120 |
"sensor_cal": False, |
| 121 |
"skip_sensor_cal": False, |
| 122 |
"integration_time": [4.0, 1.0], # Using i1D2 values |
| 123 |
"refresh": True, |
| 124 |
}, |
| 125 |
"i1 Display 1": { # Argyll 1.3.6 and newer |
| 126 |
"usb_ids": [{"vid": 0x0670, "pid": 0x0001, "hid": False}], |
| 127 |
"id": "i1D1", |
| 128 |
"spectral": False, |
| 129 |
"adaptive_mode": False, |
| 130 |
"highres_mode": False, |
| 131 |
"projector_mode": False, |
| 132 |
"sensor_cal": True, |
| 133 |
"skip_sensor_cal": False, |
| 134 |
"integration_time": [4.0, 1.0], # Using i1D2 values |
| 135 |
"refresh": True, |
| 136 |
}, |
| 137 |
"i1 Display 2": { # Argyll 1.3.6 and newer |
| 138 |
"usb_ids": [{"vid": 0x0971, "pid": 0x2003, "hid": False}], |
| 139 |
"id": "i1D2", |
| 140 |
"spectral": False, |
| 141 |
"adaptive_mode": False, |
| 142 |
"highres_mode": False, |
| 143 |
"projector_mode": False, |
| 144 |
"sensor_cal": False, |
| 145 |
"skip_sensor_cal": False, # i1 Display 2 instrument access fails |
| 146 |
# when using -N option to skip automatic sensor calibration |
| 147 |
# (dispread -D9 output: "Setting no-sensor_calibrate failed |
| 148 |
# with 'Unsupported function'") |
| 149 |
"integration_time": [4.0, 1.0], # Measured |
| 150 |
"refresh": True, |
| 151 |
}, |
| 152 |
"i1 DisplayPro, ColorMunki Display": { |
| 153 |
"usb_ids": [{"vid": 0x0765, "pid": 0x5020, "hid": True}], |
| 154 |
"id": "i1D3", |
| 155 |
"spectral": False, |
| 156 |
"adaptive_mode": False, |
| 157 |
"highres_mode": False, |
| 158 |
"projector_mode": False, |
| 159 |
"sensor_cal": False, |
| 160 |
"skip_sensor_cal": False, |
| 161 |
"measurement_mode_map": {"c": "r", "l": "n"}, |
| 162 |
"integration_time": [2.6, 0.2], # Measured |
| 163 |
"refresh": True, |
| 164 |
"spectral_cal": True, |
| 165 |
}, |
| 166 |
"i1 Monitor": { # like i1Pro |
| 167 |
"usb_ids": [{"vid": 0x0971, "pid": 0x2001, "hid": False}], |
| 168 |
"spectral": True, |
| 169 |
"adaptive_mode": True, |
| 170 |
"highres_mode": True, |
| 171 |
"projector_mode": False, |
| 172 |
"sensor_cal": True, |
| 173 |
"skip_sensor_cal": True, |
| 174 |
"integration_time": [9.2, 3.9], # Using i1 Pro values |
| 175 |
"refresh": True, |
| 176 |
}, |
| 177 |
"i1 Pro": { |
| 178 |
"usb_ids": [{"vid": 0x0971, "pid": 0x2000, "hid": False}], |
| 179 |
"spectral": True, |
| 180 |
"adaptive_mode": True, |
| 181 |
"highres_mode": True, |
| 182 |
"projector_mode": False, |
| 183 |
"sensor_cal": True, |
| 184 |
"skip_sensor_cal": True, |
| 185 |
"integration_time": [9.2, 3.9], # Measured (i1 Pro Rev. A) |
| 186 |
"refresh": True, |
| 187 |
}, |
| 188 |
"i1 Pro 2": { |
| 189 |
"usb_ids": [{"vid": 0x0971, "pid": 0x2000, "hid": False}], |
| 190 |
"spectral": True, |
| 191 |
"adaptive_mode": True, |
| 192 |
"highres_mode": True, |
| 193 |
"projector_mode": False, |
| 194 |
"sensor_cal": True, |
| 195 |
"skip_sensor_cal": True, |
| 196 |
"integration_time": [9.2, 3.9], # Using i1 Pro values |
| 197 |
"refresh": True, |
| 198 |
}, |
| 199 |
"i1 Pro 3": { |
| 200 |
"usb_ids": [{"vid": 0x0765, "pid": 0x6009, "hid": False}], |
| 201 |
"spectral": True, |
| 202 |
"adaptive_mode": True, |
| 203 |
"highres_mode": True, |
| 204 |
"projector_mode": False, |
| 205 |
"sensor_cal": True, |
| 206 |
"skip_sensor_cal": True, |
| 207 |
"integration_time": [9.2, 3.9], # Still just using i1 Pro values |
| 208 |
"refresh": True, |
| 209 |
}, |
| 210 |
"ColorHug": { |
| 211 |
"usb_ids": [ |
| 212 |
{"vid": 0x04D8, "pid": 0xF8DA, "hid": True}, |
| 213 |
{"vid": 0x273F, "pid": 0x1001, "hid": True}, |
| 214 |
], |
| 215 |
"spectral": False, |
| 216 |
"adaptive_mode": False, |
| 217 |
"highres_mode": False, |
| 218 |
"projector_mode": False, |
| 219 |
"sensor_cal": None, |
| 220 |
"skip_sensor_cal": None, |
| 221 |
"integration_time": [1.8, 0.8], # Measured (ColorHug #660) |
| 222 |
"refresh": True, |
| 223 |
}, |
| 224 |
"ColorHug2": { |
| 225 |
"usb_ids": [{"vid": 0x273F, "pid": 0x1004, "hid": True}], |
| 226 |
"spectral": False, |
| 227 |
"adaptive_mode": False, |
| 228 |
"highres_mode": False, |
| 229 |
"projector_mode": False, |
| 230 |
"sensor_cal": None, |
| 231 |
"skip_sensor_cal": None, |
| 232 |
"integration_time": [2.0, 0.6], # Measured (ColorHug2 prototype #2) |
| 233 |
"refresh": True, |
| 234 |
}, |
| 235 |
"ColorMunki": { |
| 236 |
"usb_ids": [ |
| 237 |
{"vid": 0x0971, "pid": 0x2007, "hid": False}, |
| 238 |
{"vid": 0x0765, "pid": 0x6008, "hid": False}, # ColorMunki i1Studio |
| 239 |
], |
| 240 |
"spectral": True, |
| 241 |
"adaptive_mode": True, |
| 242 |
"highres_mode": True, |
| 243 |
"projector_mode": True, |
| 244 |
"sensor_cal": True, |
| 245 |
"skip_sensor_cal": True, |
| 246 |
"integration_time": [9.2, 3.9], # Using i1 Pro values |
| 247 |
"refresh": True, |
| 248 |
}, |
| 249 |
"Colorimtre HCFR": { |
| 250 |
"usb_ids": [ |
| 251 |
{"vid": 0x04DB, "pid": 0x005B, "hid": False}, # V3.1 |
| 252 |
{"vid": 0x04D8, "pid": 0xFE17, "hid": False}, # V4.0 |
| 253 |
], |
| 254 |
"id": "HCFR", |
| 255 |
"spectral": False, |
| 256 |
"adaptive_mode": False, |
| 257 |
"highres_mode": False, |
| 258 |
"projector_mode": False, |
| 259 |
"sensor_cal": None, |
| 260 |
"skip_sensor_cal": None, |
| 261 |
}, |
| 262 |
"ColorMunki Smile": { # Argyll 1.5.x and newer |
| 263 |
"usb_ids": [{"vid": 0x0765, "pid": 0x6003, "hid": False}], |
| 264 |
"id": "Smile", |
| 265 |
"spectral": False, |
| 266 |
"adaptive_mode": False, |
| 267 |
"highres_mode": False, |
| 268 |
"projector_mode": False, |
| 269 |
"sensor_cal": False, |
| 270 |
"skip_sensor_cal": False, |
| 271 |
"integration_time": [4.0, 1.0], # Using i1D2 values |
| 272 |
}, |
| 273 |
"EX1": { |
| 274 |
"usb_ids": [{"vid": 0x2457, "pid": 0x4000, "hid": False}], |
| 275 |
"spectral": True, |
| 276 |
"adaptive_mode": False, |
| 277 |
"highres_mode": False, |
| 278 |
"projector_mode": False, |
| 279 |
"sensor_cal": True, |
| 280 |
"skip_sensor_cal": True, |
| 281 |
"integration_time": [9.2, 3.9], # Using i1 Pro values |
| 282 |
}, |
| 283 |
"K-10": { |
| 284 |
"spectral": False, |
| 285 |
"adaptive_mode": False, |
| 286 |
"highres_mode": False, |
| 287 |
"projector_mode": False, |
| 288 |
"sensor_cal": None, |
| 289 |
"skip_sensor_cal": None, |
| 290 |
"integration_time": [1.1, 0.1], # Using i1D3 values halved |
| 291 |
"refresh": True, |
| 292 |
}, |
| 293 |
"Spyder1": { |
| 294 |
"usb_ids": [{"vid": 0x085C, "pid": 0x0100, "hid": False}], |
| 295 |
"spectral": False, |
| 296 |
"adaptive_mode": False, |
| 297 |
"highres_mode": False, |
| 298 |
"projector_mode": False, |
| 299 |
"sensor_cal": None, |
| 300 |
"skip_sensor_cal": None, |
| 301 |
"integration_time": [10.5, 2.3], # Using Spyder3 values |
| 302 |
}, |
| 303 |
"Spyder2": { |
| 304 |
"usb_ids": [{"vid": 0x085C, "pid": 0x0200, "hid": False}], |
| 305 |
"spectral": False, |
| 306 |
"adaptive_mode": False, |
| 307 |
"highres_mode": False, |
| 308 |
"projector_mode": False, |
| 309 |
"sensor_cal": None, |
| 310 |
"skip_sensor_cal": None, |
| 311 |
"integration_time": [10.5, 2.3], # Using Spyder3 values |
| 312 |
"refresh": True, |
| 313 |
}, |
| 314 |
"Spyder3": { |
| 315 |
"usb_ids": [{"vid": 0x085C, "pid": 0x0300, "hid": False}], |
| 316 |
"spectral": False, |
| 317 |
"adaptive_mode": False, |
| 318 |
"highres_mode": False, |
| 319 |
"projector_mode": False, |
| 320 |
"sensor_cal": None, |
| 321 |
"skip_sensor_cal": None, |
| 322 |
"measurement_mode_map": {"c": "r", "l": "n"}, |
| 323 |
"integration_time": [10.5, 2.3], # Estimated |
| 324 |
"refresh": True, |
| 325 |
}, |
| 326 |
"Spyder4": { |
| 327 |
"usb_ids": [{"vid": 0x085C, "pid": 0x0400, "hid": False}], |
| 328 |
"spectral": False, |
| 329 |
"adaptive_mode": False, |
| 330 |
"highres_mode": False, |
| 331 |
"projector_mode": False, |
| 332 |
"sensor_cal": None, |
| 333 |
"skip_sensor_cal": None, |
| 334 |
"measurement_mode_map": {"c": "r", "l": "n"}, |
| 335 |
"integration_time": [10.5, 2.3], # Using Spyder3 values |
| 336 |
"refresh": True, |
| 337 |
"spectral_cal": True, |
| 338 |
}, |
| 339 |
"Spyder5": { |
| 340 |
"usb_ids": [{"vid": 0x085C, "pid": 0x0500, "hid": False}], |
| 341 |
"spectral": False, |
| 342 |
"adaptive_mode": False, |
| 343 |
"highres_mode": False, |
| 344 |
"projector_mode": False, |
| 345 |
"sensor_cal": None, |
| 346 |
"skip_sensor_cal": None, |
| 347 |
"measurement_mode_map": {"c": "r", "l": "n"}, |
| 348 |
"integration_time": [10.5, 2.3], # Using Spyder3 values |
| 349 |
"refresh": True, |
| 350 |
"spectral_cal": True, |
| 351 |
}, |
| 352 |
"SpyderX": { |
| 353 |
"usb_ids": [{"vid": 0x085C, "pid": 0x0A00, "hid": False}], |
| 354 |
"spectral": False, |
| 355 |
"adaptive_mode": False, |
| 356 |
"highres_mode": False, |
| 357 |
"projector_mode": False, |
| 358 |
"sensor_cal": True, |
| 359 |
"skip_sensor_cal": True, # Not yet officially, but likely supported in future |
| 360 |
"integration_time": [1.6, 1.6], |
| 361 |
"refresh": False, |
| 362 |
}, |
| 363 |
"SpyderX2": { |
| 364 |
"usb_ids": [{"vid": 0x085C, "pid": 0x0A0B, "hid": False}], |
| 365 |
"spectral": False, |
| 366 |
"adaptive_mode": False, |
| 367 |
"highres_mode": False, |
| 368 |
"projector_mode": False, |
| 369 |
"sensor_cal": True, |
| 370 |
"skip_sensor_cal": True, |
| 371 |
"integration_time": [1.6, 1.6], # Using SpyderX values until measured |
| 372 |
"refresh": False, |
| 373 |
}, |
| 374 |
"Spyder 2024": { |
| 375 |
"usb_ids": [{"vid": 0x085C, "pid": 0x0A0B, "hid": False}], |
| 376 |
"spectral": False, |
| 377 |
"adaptive_mode": False, |
| 378 |
"highres_mode": False, |
| 379 |
"projector_mode": False, |
| 380 |
"sensor_cal": True, |
| 381 |
"skip_sensor_cal": True, |
| 382 |
"integration_time": [1.6, 1.6], # Using SpyderX values until measured |
| 383 |
"refresh": False, |
| 384 |
}, |
| 385 |
"Huey": { |
| 386 |
"usb_ids": [ |
| 387 |
{"vid": 0x0971, "pid": 0x2005, "hid": True}, |
| 388 |
{"vid": 0x0765, "pid": 0x5001, "hid": True}, # HueyL |
| 389 |
{"vid": 0x0765, "pid": 0x5010, "hid": True}, # HueyL |
| 390 |
], |
| 391 |
"spectral": False, |
| 392 |
"adaptive_mode": False, |
| 393 |
"highres_mode": False, |
| 394 |
"projector_mode": False, |
| 395 |
"sensor_cal": None, |
| 396 |
"skip_sensor_cal": None, |
| 397 |
"integration_time": [4.0, 1.0], # Using i1D2 values |
| 398 |
}, |
| 399 |
"specbos": { |
| 400 |
"spectral": True, |
| 401 |
"adaptive_mode": False, |
| 402 |
"highres_mode": False, |
| 403 |
"projector_mode": False, |
| 404 |
"sensor_cal": None, |
| 405 |
"skip_sensor_cal": None, |
| 406 |
"measurement_mode_map": {"c": "r", "l": "n"}, |
| 407 |
"integration_time": [3.3, 0.8], # Estimated, VERY rough |
| 408 |
"refresh": True, |
| 409 |
}, |
| 410 |
"specbos 1201": { |
| 411 |
"spectral": True, |
| 412 |
"adaptive_mode": False, |
| 413 |
"highres_mode": False, |
| 414 |
"projector_mode": False, |
| 415 |
"sensor_cal": None, |
| 416 |
"skip_sensor_cal": None, |
| 417 |
"integration_time": [10.3, 2.8], # Estimated, VERY rough |
| 418 |
"refresh": True, |
| 419 |
}, |
| 420 |
"spectraval": { |
| 421 |
"spectral": True, |
| 422 |
"adaptive_mode": False, |
| 423 |
"highres_mode": False, |
| 424 |
"projector_mode": False, |
| 425 |
"sensor_cal": None, |
| 426 |
"skip_sensor_cal": None, |
| 427 |
"integration_time": [3.3, 0.8], # Estimated, VERY rough |
| 428 |
"refresh": True, |
| 429 |
}, |
| 430 |
"Dummy Meter / Hires & Projector": { |
| 431 |
# dummy instrument, just for testing |
| 432 |
"spectral": False, |
| 433 |
"adaptive_mode": False, |
| 434 |
"highres_mode": True, |
| 435 |
"projector_mode": True, |
| 436 |
"sensor_cal": False, |
| 437 |
"skip_sensor_cal": False, |
| 438 |
}, |
| 439 |
"Dummy Spectro / Hires & Projector": { |
| 440 |
# dummy instrument, just for testing |
| 441 |
"spectral": True, |
| 442 |
"adaptive_mode": False, |
| 443 |
"highres_mode": True, |
| 444 |
"projector_mode": True, |
| 445 |
"sensor_cal": True, |
| 446 |
"skip_sensor_cal": True, |
| 447 |
}, |
| 448 |
"Dummy Meter / Adaptive, Hires & Projector": { |
| 449 |
# dummy instrument, just for testing |
| 450 |
"spectral": False, |
| 451 |
"adaptive_mode": True, |
| 452 |
"highres_mode": True, |
| 453 |
"projector_mode": True, |
| 454 |
"sensor_cal": False, |
| 455 |
"skip_sensor_cal": False, |
| 456 |
}, |
| 457 |
"Dummy Spectro / Adaptive, Hires & Projector": { |
| 458 |
# dummy instrument, just for testing |
| 459 |
"spectral": True, |
| 460 |
"adaptive_mode": True, |
| 461 |
"highres_mode": True, |
| 462 |
"projector_mode": True, |
| 463 |
"sensor_cal": True, |
| 464 |
"skip_sensor_cal": True, |
| 465 |
}, |
| 466 |
} |
| 467 |
|
| 468 |
vendors = [ |
| 469 |
"ColorVision", |
| 470 |
"Datacolor", |
| 471 |
"GretagMacbeth", |
| 472 |
"Hughski", |
| 473 |
"Image Engineering", |
| 474 |
"JETI", |
| 475 |
"Klein", |
| 476 |
"X-Rite", |
| 477 |
"Xrite", |
| 478 |
] |
| 479 |
|
| 480 |
|
| 481 |
def get_canonical_instrument_name( |
| 482 |
instrument_name: bytes | str, |
| 483 |
replacements: None | dict = None, |
| 484 |
inverse: bool = False, |
| 485 |
) -> str: |
| 486 |
"""Get canonical instrument name. |
| 487 |
|
| 488 |
This function removes vendor names from the instrument name and replaces |
| 489 |
the instrument name with a canonical name if it is found in the |
| 490 |
replacements dictionary. |
| 491 |
|
| 492 |
Args: |
| 493 |
instrument_name (bytes, str): Instrument name to be canonicalized. |
| 494 |
replacements (dict): Dictionary of replacements. The keys are the |
| 495 |
canonical names and the values are the instrument names to be |
| 496 |
replaced. If None, no replacements are made. |
| 497 |
inverse (bool): If True, the replacements are inverted. The keys are |
| 498 |
the instrument names and the values are the canonical names. If |
| 499 |
False, the replacements are not inverted. Default is False. |
| 500 |
|
| 501 |
Returns: |
| 502 |
str: Canonical instrument name. |
| 503 |
""" |
| 504 |
replacements = replacements or {} |
| 505 |
if inverse: |
| 506 |
replacements = dict(zip(iter(replacements.values()), iter(replacements.keys()))) |
| 507 |
return strtr(remove_vendor_names(instrument_name), replacements) |
| 508 |
|
| 509 |
|
| 510 |
def remove_vendor_names(txt: str) -> str: |
| 511 |
"""Remove vendor names from the instrument name. |
| 512 |
|
| 513 |
Args: |
| 514 |
txt (bytes, str): Instrument name to be processed. |
| 515 |
|
| 516 |
Returns: |
| 517 |
str: Instrument name without vendor names. |
| 518 |
""" |
| 519 |
for vendor in vendors: |
| 520 |
if isinstance(txt, bytes): |
| 521 |
txt = re.sub( |
| 522 |
re.compile(re.escape(bytes(vendor, "utf-8")) + rb"\s*", re.I), b"", txt |
| 523 |
) |
| 524 |
elif isinstance(txt, str): |
| 525 |
txt = re.sub(re.compile(re.escape(vendor) + r"\s*", re.I), "", txt) |
| 526 |
txt = txt.strip() |
| 527 |
return txt |