Trace File Converter¶
              TraceFileConverter(input_file='', output_file='')
¶
    Converter class that will convert save files for the Java-based Archive Viewer into a format readable by the Trace application. This class can also be used for importing data into Trace or exporting data from it.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
                input_file
             | 
            
                  str | Path
             | 
            
               Path to the file to import/convert. Can be set later via
  | 
            
                  ''
             | 
          
                output_file
             | 
            
                  str | Path
             | 
            
               Path to the destination Trace file for export. Can be set later via
  | 
            
                  ''
             | 
          
Source code in trace/file_io/trace_file_convert.py
                    40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55  |  | 
            import_is_xml()
¶
    Helper function to determine if the import file is in XML format.
Source code in trace/file_io/trace_file_convert.py
              57 58 59 60  |  | 
            import_is_stp()
¶
    Helper function to determine if the import file is a StripTool file.
Source code in trace/file_io/trace_file_convert.py
              62 63 64 65  |  | 
            import_file(file_name=None)
¶
    Import Archive Viewer save data from the provided file. The file should be one of two types: '.trc' or '.xml'. The data is returned as well as saved in the stored_data property.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
                file_name
             | 
            
                  str or Path
             | 
            
               The absolute filepath for the input file to import  | 
            
                  None
             | 
          
Returns:
| Type | Description | 
|---|---|
                  dict
             | 
            
               A python dictionaty containing the data imported from the provided file  | 
          
Source code in trace/file_io/trace_file_convert.py
              67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101  |  | 
            export_file(file_name=None, output_data=None)
¶
    Export the provided Archive Viewer save data to the provided file. The file to export to should be of type '.trc'. The provided data can be either a dictionary or a PyDMTimePlot object. If no data is provided, then the converter's previously imported data is exported.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
                file_name
             | 
            
                  str or Path
             | 
            
               The absolute file path of the file that save data should be written to. Should be of file type '.trc'.  | 
            
                  None
             | 
          
                output_data
             | 
            
                  dict or PyDMTimePlot
             | 
            
               The data that should be exported, by default uses previously imported data  | 
            
                  None
             | 
          
Raises:
| Type | Description | 
|---|---|
                  FileNotFoundError
             | 
            
               If the provided file name does not match the expected output file type '.trc'  | 
          
                  ValueError
             | 
            
               If no output data is provided and the converter hasn't imported data previously  | 
          
Source code in trace/file_io/trace_file_convert.py
              103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143  |  | 
            convert_xml_data(data_in={})
¶
    Convert the inputted data from being formatted for the Java Archive Viewer to a format used by trace. This is accomplished by converting one dictionary structure to another.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
                data_in
             | 
            
                  dict
             | 
            
               The input data to be converted, by default uses previously imported data  | 
            
                  {}
             | 
          
Returns:
| Type | Description | 
|---|---|
                  dict
             | 
            
               The converted data in a format that can be used by trace  | 
          
Source code in trace/file_io/trace_file_convert.py
              145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223  |  | 
            convert_stp_data(data_in={})
¶
    Convert the inputted data from a format used by StripTool to a format used by Trace. This is accomplished by converting one dictionary structure to another.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
                data_in
             | 
            
                  dict
             | 
            
               The input data to be converted, by default uses previously imported data  | 
            
                  {}
             | 
          
Returns:
| Type | Description | 
|---|---|
                  dict
             | 
            
               The converted data in a format that can be used by trace  | 
          
Source code in trace/file_io/trace_file_convert.py
              225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300  |  | 
            reformat_date(input_str)
  
      classmethod
  
¶
    Convert a time string from the format 'MM/DD/YYYY' --> 'YYYY-MM-DD' and retain time if included
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
                input_str
             | 
            
                  str
             | 
            
               Date string in the format of 'MM/DD/YYYY'; can include a time  | 
            required | 
Returns:
| Type | Description | 
|---|---|
                  str
             | 
            
               Date string in the format of 'YYYY-MM-DD'  | 
          
Source code in trace/file_io/trace_file_convert.py
              302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327  |  | 
            xml_to_dict(xml)
  
      staticmethod
  
¶
    Convert an XML ElementTree containing an Archive Viewer save file to a dictionary for easier use
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
                xml
             | 
            
                  ElementTree
             | 
            
               The XML ElementTree object read from the file  | 
            required | 
Returns:
| Type | Description | 
|---|---|
                  dict
             | 
            
               The data in a dictionary format  | 
          
Source code in trace/file_io/trace_file_convert.py
              329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375  |  | 
            stp_to_dict(stp_text)
  
      staticmethod
  
¶
    Convert the StripTool file's text into a dictionary.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
                stp_text
             | 
            
                  str
             | 
            
               The full file text from the StripTool file  | 
            required | 
Returns:
| Type | Description | 
|---|---|
                  dict
             | 
            
               The data in a dictionary format  | 
          
Source code in trace/file_io/trace_file_convert.py
              377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416  |  | 
            get_plot_data(plot)
  
      classmethod
  
¶
    Extract plot, axis, and curve data from a PyDMTimePlot object
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
                plot
             | 
            
                  PyDMTimePlot
             | 
            
               The PyDM Plotting object to extract data from. Gets plot, axis, and curve data.  | 
            required | 
Returns:
| Type | Description | 
|---|---|
                  dict
             | 
            
               A dictionary representation of all of the relevant data for the given plot  | 
          
Source code in trace/file_io/trace_file_convert.py
              418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477  |  | 
            delta_to_relative(delta)
  
      staticmethod
  
¶
    Convert a datetime.timedelta to a relative time string
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
                delta
             | 
            
                  timedelta
             | 
            
               The timedelta to convert  | 
            required | 
Returns:
| Type | Description | 
|---|---|
                  str
             | 
            
               A string representing the timedelta in a relative format  | 
          
Source code in trace/file_io/trace_file_convert.py
              479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523  |  | 
            srgb_to_qColor(srgb)
  
      staticmethod
  
¶
    Convert RGB strings to QColors. The string is a 32-bit integer containing the aRGB values of a color. (e.g. #FF0000 or -65536)
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
                srgb
             | 
            
                  str
             | 
            
               Either a hex value or a string containing a signed 32-bit integer  | 
            required | 
Returns:
| Type | Description | 
|---|---|
                  QColor
             | 
            
               A QColor object storing the color described in the string  | 
          
Source code in trace/file_io/trace_file_convert.py
              525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545  |  | 
            xColor_to_qColor(rgb)
  
      staticmethod
  
¶
    Convert XColor values into QColors. Colors in StripTool files (*.stp) are saved as XColors.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
                rgb
             | 
            
                  list(str)
             | 
            
               A list of strings containing the rgb values (0 <= rgb < 0xFFFF)  | 
            required | 
Returns:
| Type | Description | 
|---|---|
                  QColor
             | 
            
               A QColor object storing the color described in the string  | 
          
Source code in trace/file_io/trace_file_convert.py
              547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565  |  | 
            remove_null_values(obj_in)
  
      staticmethod
  
¶
    Delete None values recursively from all of the dictionaries, tuples, lists, sets
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
                obj_in
             | 
            
                  dict | list
             | 
            
               Some dictionary, possibly containing key-value pairs where value is None  | 
            required | 
Returns:
| Type | Description | 
|---|---|
                  dict
             | 
            
               The same dictionary, but with those key-value pairs deleted  | 
          
Source code in trace/file_io/trace_file_convert.py
              567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596  |  | 
            PathAction
¶
    
              Bases: Action
            __call__(parser, namespace, values, option_string=None)
¶
    Convert filepath string from argument into a pathlib.Path object
Source code in trace/file_io/trace_file_convert.py
              678 679 680 681 682 683 684 685 686 687 688 689 690 691  |  | 
            convert(converter, input_file=None, output_file=None, overwrite=False)
¶
    Individually convert the provided input file into the expected output file. If requested, overwrite the existing output file if it exists already.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
                converter
             | 
            
                  TraceFileConverter
             | 
            
               The TraceFileConverter object to use for the conversion.  | 
            required | 
                input_file
             | 
            
                  list[Path]
             | 
            
               The user provided input file to be converted  | 
            
                  None
             | 
          
                output_file
             | 
            
                  list[Path]
             | 
            
               The user provided output file name to use during conversion, by default None  | 
            
                  None
             | 
          
                overwrite
             | 
            
                  bool
             | 
            
               Whether or not to overwrite the existing output file, by default False  | 
            
                  False
             | 
          
Source code in trace/file_io/trace_file_convert.py
              599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635  |  | 
            main(input_file=None, output_file=None, overwrite=False, clean=False)
¶
    Convert all provided input files into the expected output files. If requested, overwrite the existing output files and remove any leftover input files.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
                input_file
             | 
            
                  list[Path]
             | 
            
               The user provided input files to be converted  | 
            
                  None
             | 
          
                output_file
             | 
            
                  list[Path]
             | 
            
               The user provided output file names to use during conversion, by default None  | 
            
                  None
             | 
          
                overwrite
             | 
            
                  bool
             | 
            
               Whether or not to overwrite the existing output files, by default False  | 
            
                  False
             | 
          
                clean
             | 
            
                  bool
             | 
            
               Whether or not to remove the input files after conversion, by default False  | 
            
                  False
             | 
          
Source code in trace/file_io/trace_file_convert.py
              638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674  |  |