Example #1
0
    def __init__(self, data_type, ErMagicCheck, grid, belongs_to):
        """
        take: data_type (string), ErMagicCheck (top level class object for ErMagic steps 1-6),
        grid (grid object), belongs_to (list of options for data object to belong to, i.e. locations for the site Menus)
        """
        # if controlled vocabularies haven't already been grabbed from earthref
        # do so now
        if not any(vocab.vocabularies):
            vocab.get_all_vocabulary()

        self.data_type = data_type
        self.check = ErMagicCheck # check is top level class object for entire ErMagic steps 1-6
        self.grid = grid
        self.window = grid.Parent # parent window in which grid resides
        self.belongs_to = []
        # belongs_to can either be a list of strings OR a list of Pmag_objects
        if belongs_to:
            for item in belongs_to:
                try:
                    self.belongs_to.append(item.name)
                except AttributeError:
                    self.belongs_to.append(item)
        #self.headers = headers
        self.selected_col = None
        self.selection = [] # [(row, col), (row, col)], sequentially down a column
        self.dispersed_selection = [] # [(row, col), (row, col)], not sequential
        self.col_color = None
        self.colon_delimited_lst = ['specimen_type', 'specimen_class', 'specimen_lithology',
                                    'sample_type', 'sample_class', 'sample_lithology',
                                    'site_type', 'site_class', 'site_lithology',
                                    'er_specimen_names', 'er_sample_names', 'er_site_names',
                                    'er_location_names', 'magic_method_codes', 'magic_method_codes++']
        self.InitUI()
Example #2
0
    def __init__(self, data_type, ErMagicCheck, grid, belongs_to):
        """
        take: data_type (string), ErMagicCheck (top level class object for ErMagic steps 1-6),
        grid (grid object), belongs_to (list of options for data object to belong to, i.e. locations for the site Menus)
        """
        # if controlled vocabularies haven't already been grabbed from earthref
        # do so now
        if not any(vocab.vocabularies):
            vocab.get_all_vocabulary()

        self.data_type = data_type
        self.check = ErMagicCheck # check is top level class object for entire ErMagic steps 1-6
        self.grid = grid
        self.window = grid.Parent # parent window in which grid resides
        self.belongs_to = []
        # belongs_to can either be a list of strings OR a list of Pmag_objects
        if belongs_to:
            for item in belongs_to:
                try:
                    self.belongs_to.append(item.name)
                except AttributeError:
                    self.belongs_to.append(item)
        #self.headers = headers
        self.selected_col = None
        self.selection = [] # [(row, col), (row, col)], sequentially down a column
        self.dispersed_selection = [] # [(row, col), (row, col)], not sequential
        self.col_color = None
        self.colon_delimited_lst = ['specimen_type', 'specimen_class', 'specimen_lithology',
                                    'sample_type', 'sample_class', 'sample_lithology',
                                    'site_type', 'site_class', 'site_lithology',
                                    'er_specimen_names', 'er_sample_names', 'er_site_names',
                                    'er_location_names', 'magic_method_codes', 'magic_method_codes++']
        self.InitUI()
Example #3
0
def validate_for_controlled_vocab(key, value, complete_ref):

    if not any(vocab.vocabularies):
        vocab.get_all_vocabulary()
    #
    cv = False
    stripped_key = ''
    for level in ['specimen_', 'sample_', 'site_']:
        if key.startswith(level):
            #stripped_key = key.strip(level)
            stripped_key = key[len(level):]
            break
    #print 'key', key
    #print 'stripped_key', stripped_key
    if key in vocab.possible_vocabularies or key in vocab.vocabularies:
        cv = True
    elif stripped_key in vocab.possible_vocabularies or stripped_key in vocab.vocabularies:
        cv = True
        key = stripped_key
        #return key

    #if there is a controlled vocabulary for the given header,
    # check and see if all values provided are legitimate
    if cv:
        # make sure colon-delimited lists are split
        values = value.split(':')
        values = [v.strip() for v in values]
        #print 'key', key
        #print 'values', values

        ## Not anymore
        # if we don't have the options for the needed controlled vocabulary,
        # fetch them from earthref
        #if key not in vocab.vocabularies:
        #    add = vocab.get_controlled_vocabularies((key,))
        #    vocab.vocabularies = pd.concat((vocab.vocabularies, add[0]), sort=True)

        ## for each value from a controlled vocabulary header,
        ## make sure it is within the controlled vocabulary list
        ## and that the value is not null
        for val in values:
            if val not in vocab.vocabularies[key] and val:
                if isinstance(vocab.vocabularies[key], dict):
                    if val not in vocab.vocabularies[key][val[0].upper()]:
                        return key
                else:
                    return key
Example #4
0
    def __init__(self, ErMagic, WD=None, frame_name="grid frame",
                 panel_name="grid panel", parent=None):
        self.parent = parent
        wx.GetDisplaySize()
        title = 'Edit {} data'.format(panel_name)
        #wx.Frame.__init__(self, parent=parent, id=wx.ID_ANY, name=frame_name, title=title)
        #wx.ScrolledWindow.__init__(self, parent=parent, id=wx.ID_ANY, name=frame_name)#, title=title)
        super(GridFrame, self).__init__(parent=parent, id=wx.ID_ANY, name=frame_name, title=title)

        # if controlled vocabularies haven't already been grabbed from earthref
        # do so now
        if not any(vocab.vocabularies):
            vocab.get_all_vocabulary()

        self.remove_cols_mode = False
        self.deleteRowButton = None
        self.selected_rows = set()

        self.er_magic = ErMagic

        self.panel = wx.Panel(self, name=panel_name, size=wx.GetDisplaySize())
        self.grid_type = panel_name

        if self.parent:
            self.Bind(wx.EVT_WINDOW_DESTROY, self.parent.Parent.on_close_grid_frame)

        if self.grid_type == 'age':
            ancestry_ind = self.er_magic.ancestry.index(self.er_magic.age_type)
            self.child_type = self.er_magic.ancestry[ancestry_ind-1]
            self.parent_type = self.er_magic.ancestry[ancestry_ind+1]
        else:
            try:
                child_ind = self.er_magic.ancestry.index(self.grid_type) - 1
                self.child_type = self.er_magic.ancestry[child_ind]
                parent_ind = self.er_magic.ancestry.index(self.grid_type) + 1
                self.parent_type = self.er_magic.ancestry[parent_ind]
            except ValueError:
                self.child_type = None
                self.parent_type = None

        self.WD = WD
        self.InitUI()
Example #5
0
    def __init__(self, ErMagic, WD=None, frame_name="grid frame",
                 panel_name="grid panel", parent=None):
        self.parent = parent
        wx.GetDisplaySize()
        title = 'Edit {} data'.format(panel_name)
        #wx.Frame.__init__(self, parent=parent, id=wx.ID_ANY, name=frame_name, title=title)
        #wx.ScrolledWindow.__init__(self, parent=parent, id=wx.ID_ANY, name=frame_name)#, title=title)
        super(GridFrame, self).__init__(parent=parent, id=wx.ID_ANY, name=frame_name, title=title)

        # if controlled vocabularies haven't already been grabbed from earthref
        # do so now
        if not any(vocab.vocabularies):
            vocab.get_all_vocabulary()

        self.remove_cols_mode = False
        self.deleteRowButton = None
        self.selected_rows = set()

        self.er_magic = ErMagic

        self.panel = wx.Panel(self, name=panel_name, size=wx.GetDisplaySize())
        self.grid_type = panel_name

        if self.parent:
            self.Bind(wx.EVT_WINDOW_DESTROY, self.parent.Parent.on_close_grid_frame)

        if self.grid_type == 'age':
            ancestry_ind = self.er_magic.ancestry.index(self.er_magic.age_type)
            self.child_type = self.er_magic.ancestry[ancestry_ind-1]
            self.parent_type = self.er_magic.ancestry[ancestry_ind+1]
        else:
            try:
                child_ind = self.er_magic.ancestry.index(self.grid_type) - 1
                self.child_type = self.er_magic.ancestry[child_ind]
                parent_ind = self.er_magic.ancestry.index(self.grid_type) + 1
                self.parent_type = self.er_magic.ancestry[parent_ind]
            except ValueError:
                self.child_type = None
                self.parent_type = None

        self.WD = WD
        self.InitUI()