Changeset e090c624 in sasview for src/sans/dataloader/readers/cansas_constants.py
- Timestamp:
- Jan 27, 2014 3:35:28 PM (11 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.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 64beda4
- Parents:
- 16bd5ca
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sans/dataloader/readers/cansas_constants.py
r76cd1ae re090c624 8 8 format = '' 9 9 10 10 11 def __init__(self): 11 12 self.ns = self.CANSAS_NS 12 13 self.format = self.CANSAS_FORMAT 14 15 16 def _iterate_namespace(self, namespace): 17 """ 18 Method to iterate through a cansas constants tree based on a list of 19 names 20 21 :param namespace: A list of names that match the tree structure of 22 cansas_constants 23 """ 24 # The current level to look through in cansas_constants. 25 return_me = currentLevel() 26 return_me.current_level = self.CANSAS_FORMAT.get("SASentry") 27 # Defaults for variable and datatype 28 return_me.ns_variable = "{0}.meta_data[\"{2}\"] = \"{1}\"" 29 return_me.ns_datatype = "content" 30 return_me.ns_optional = True 31 for name in namespace: 32 if name != "SASentry": 33 return_me.current_level = \ 34 return_me.current_level.get("children").get(name, "") 35 if return_me.current_level == "": 36 return_me.current_level = \ 37 return_me.current_level.get("<any>", "") 38 cl_variable = return_me.current_level.get("variable", "") 39 cl_datatype = return_me.current_level.get("storeas", "") 40 cl_units_optional = \ 41 return_me.current_level.get("units_required", "") 42 # Where are how to store the variable for the given namespace 43 # CANSAS_CONSTANTS tree is hierarchical, so is no value, inherit 44 return_me.ns_variable = cl_variable if cl_variable != "" else \ 45 return_me.ns_variable 46 return_me.ns_datatype = cl_datatype if cl_datatype != "" else \ 47 return_me.ns_datatype 48 return_me.ns_optional = cl_units_optional if \ 49 cl_units_optional != return_me.ns_optional \ 50 else return_me.ns_optional 51 return return_me 52 53 13 54 """ 14 55 CANSAS_NS holds the base namespace and the default schema file information … … 24 65 } 25 66 } 67 26 68 27 69 """ … … 697 739 } 698 740 } 699 741 742 class currentLevel: 743 744 current_level = '' 745 ns_variable = '' 746 ns_datatype = '' 747 ns_optional = True 748 749 def __init__(self): 750 self.current_level = '' 751 self.ns_variable = '' 752 self.ns_datatype = "content" 753 self.ns_optional = True
Note: See TracChangeset
for help on using the changeset viewer.