Changeset 270c882b in sasview for src/sas/sascalc/dataloader
- Timestamp:
- Apr 5, 2017 5:31:36 AM (8 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- cfc6f3c7
- Parents:
- b9b612a
- git-author:
- Jeff Krzywon <krzywon@…> (04/05/17 05:31:36)
- git-committer:
- krzywon <krzywon@…> (04/05/17 05:31:36)
- Location:
- src/sas/sascalc/dataloader
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/loader.py
rb9b612a r270c882b 1 1 """ 2 2 File handler to support different file extensions. 3 Uses reflectomet ry'sregistry utility.3 Uses reflectometer registry utility. 4 4 5 5 The default readers are found in the 'readers' sub-module … … 29 29 # Default readers are defined in the readers sub-module 30 30 import readers 31 from loader_exceptions import NoKnownLoaderException, FileContentsException 31 32 from readers import ascii_reader 32 33 from readers import cansas_reader 33 34 from readers import cansas_reader_HDF5 35 34 36 35 37 class Registry(ExtensionRegistry): … … 38 40 Readers and writers are supported. 39 41 """ 40 41 42 def __init__(self): 42 43 super(Registry, self).__init__() 43 44 44 # #Writers45 # Writers 45 46 self.writers = {} 46 47 47 # #List of wildcards48 # List of wildcards 48 49 self.wildcards = ['All (*.*)|*.*'] 49 50 50 # #Creation time, for testing51 # Creation time, for testing 51 52 self._created = time.time() 52 53 … … 67 68 try: 68 69 return super(Registry, self).load(path, format=format) 69 except Exception: 70 pass # try the ASCII reader 70 except NoKnownLoaderException as e: 71 pass # try the ASCII reader 72 except FileContentsException as e: 73 pass 71 74 try: 72 75 ascii_loader = ascii_reader.Reader() 73 76 return ascii_loader.read(path) 74 except Exception:75 pass # try the cansas XML reader77 except FileContentsException: 78 pass # try the cansas XML reader 76 79 try: 77 80 cansas_loader = cansas_reader.Reader() 78 81 return cansas_loader.read(path) 79 except Exception:80 pass # try the cansas NeXuS reader82 except FileContentsException: 83 pass # try the cansas NeXuS reader 81 84 try: 82 85 cansas_nexus_loader = cansas_reader_HDF5.Reader() 83 86 return cansas_nexus_loader.read(path) 84 except Exception:87 except FileContentsException: 85 88 # No known reader available. Give up and throw an error 86 89 msg = "\n\tUnknown data format: %s.\n\tThe file is not a " % path 87 msg += "known format for SasView. The most common formats are " 88 msg += "multi-column ASCII, CanSAS XML, and CanSAS NeXuS." 89 raise Exception(msg) 90 msg += "known format that can be loaded by SasView." 91 raise NoKnownLoaderException(msg) 90 92 91 93 def find_plugins(self, dir):
Note: See TracChangeset
for help on using the changeset viewer.