pypet/naturalnaming.py
def _check_names(self, split_names, parent_node=None):
        """Checks if a list contains strings with invalid names.

        Returns a description of the name violations. If names are correct the empty
        string is returned.

        :param split_names: List of strings

        :param parent_node:

            The parental node from where to start (only applicable for node names)

        """

        faulty_names = ''

        if parent_node is not None and parent_node.v_is_root and split_names[0] == 'overview':
            faulty_names = '%s `overview` cannot be added directly under the root node ' \
                           'this is a reserved keyword,' % (faulty_names)

        for split_name in split_names:

            if len(split_name) == 0:
                faulty_names = '%s `%s` contains no characters, please use at least 1,' % (
                    faulty_names, split_name)

            elif split_name.startswith('_'):
                faulty_names = '%s `%s` starts with a leading underscore,' % (
                    faulty_names, split_name)

            elif re.match(CHECK_REGEXP, split_name) is None:
                faulty_names = '%s `%s` contains non-admissible characters ' \
                               '(use only [A-Za-z0-9_-]),' % \
                               (faulty_names, split_name)

            elif '$' in split_name:
                if split_name not in self._root_instance._wildcard_keys:
                    faulty_names = '%s `%s` contains `$` but has no associated ' \
                                   'wildcard function,' % (faulty_names, split_name)

            elif split_name in self._not_admissible_names:
                warnings.warn('`%s` is a method/attribute of the '
                              'trajectory/treenode/naminginterface, you may not be '
                              'able to access it via natural naming but only by using '
                              '`[]` square bracket notation. ' % split_name,
                              category=SyntaxWarning)

            elif split_name in self._python_keywords:
                warnings.warn('`%s` is a python keyword, you may not be '
                              'able to access it via natural naming but only by using '
                              '`[]` square bracket notation. ' % split_name,
                              category=SyntaxWarning)

        name = split_names[-1]
        if len(name) >= pypetconstants.HDF5_STRCOL_MAX_NAME_LENGTH:
            faulty_names = '%s `%s` is too long the name can only have %d characters but it has ' \
                           '%d,' % \
                           (faulty_names, name, len(name),
                            pypetconstants.HDF5_STRCOL_MAX_NAME_LENGTH)

        return faulty_names
def _check_names(self, split_names, parent_node=None):
        """Checks if a list contains strings with invalid names.

        Returns a description of the name violations. If names are correct the empty
        string is returned.

        :param split_names: List of strings

        :param parent_node:

            The parental node from where to start (only applicable for node names)

        """

        faulty_names = ''

        if parent_node is not None and parent_node.v_is_root and split_names[0] == 'overview':
            faulty_names = '%s `overview` cannot be added directly under the root node ' \
                           'this is a reserved keyword,' % (faulty_names)

        for split_name in split_names:

            if len(split_name) == 0:
                faulty_names = '%s `%s` contains no characters, please use at least 1,' % (
                    faulty_names, split_name)

            elif split_name.startswith('_'):
                faulty_names = '%s `%s` starts with a leading underscore,' % (
                    faulty_names, split_name)

            elif re.match(CHECK_REGEXP, split_name) is None:
                faulty_names = '%s `%s` contains non-admissible characters ' \
                               '(use only [A-Za-z0-9_-]),' % \
                               (faulty_names, split_name)

            elif '$' in split_name:
                if split_name not in self._root_instance._wildcard_keys:
                    faulty_names = '%s `%s` contains `$` but has no associated ' \
                                   'wildcard function,' % (faulty_names, split_name)

            elif split_name in self._not_admissible_names:
                warnings.warn('`%s` is a method/attribute of the '
                              'trajectory/treenode/naminginterface, you may not be '
                              'able to access it via natural naming but only by using '
                              '`[]` square bracket notation. ' % split_name,
                              category=SyntaxWarning)

            elif split_name in self._python_keywords:
                warnings.warn('`%s` is a python keyword, you may not be '
                              'able to access it via natural naming but only by using '
                              '`[]` square bracket notation. ' % split_name,
                              category=SyntaxWarning)

        name = split_names[-1]
        if len(name) >= pypetconstants.HDF5_STRCOL_MAX_NAME_LENGTH:
            faulty_names = '%s `%s` is too long the name can only have %d characters but it has ' \
                           '%d,' % \
                           (faulty_names, name, len(name),
                            pypetconstants.HDF5_STRCOL_MAX_NAME_LENGTH)

        return faulty_names
Checks if a list contains strings with invalid names.

        Returns a description of the name violations. If names are correct the empty
        string is returned.

        :param split_names: List of strings

        :param parent_node:

            The parental node from where to start (only applicable for node names)