sidpy/sid/reader.py
def can_read(self, *args, **kwargs):
        """
        Checks whether the provided file can be read by this reader.

        This basic function compares the file extension against the
        ``extension`` keyword argument. If the extension matches, this function
        returns True

        Parameters
        ----------
        extension : str or iterable of str, Optional. Default = None
            File extension for the input file.

        Returns
        -------
        file_path : str
            Path to the file that needs to be provided to read()
            if the provided file was indeed a valid file
            Else, None

        Raises
        ------
        NotImplementedError : if this function is called for this or a child
        class that does not provide the ``extension`` keyword argument

        Notes
        -----
        It is recommended to add additional checks as necessary to ensure that
        the translator can indeed read the given file such as by validating the
        headers or similar metadata.
        """
        targ_ext = kwargs.get('extension', None)
        if not targ_ext:
            raise NotImplementedError('Either can_read() has not been '
                                      'implemented by this Reader or the '
                                      '"extension" keyword argument was '
                                      'missing')
        if isinstance(targ_ext, (str, unicode)):
            targ_ext = [targ_ext]
        targ_ext = validate_list_of_strings(targ_ext,
                                            parm_name='(keyword argument) '
                                                      '"extension"')

        # Get rid of any '.' separators that may be in the list of extensions
        # Also turn to lower case for case insensitive comparisons
        targ_ext = [item.replace('.', '').lower() for item in targ_ext]

        file_path = os.path.abspath(self._input_file_path)
        extension = os.path.splitext(file_path)[1][1:]

        # Ensure extension is lower case just like targets above
        extension = extension.lower()

        if extension in targ_ext:
            return file_path
        else:
            return None

        Checks whether the provided file can be read by this reader.

        This basic function compares the file extension against the
        ``extension`` keyword argument. If the extension matches, this function
        returns True

        Parameters
        ----------
        extension : str or iterable of str, Optional. Default = None
            File extension for the input file.

        Returns
        -------
        file_path : str
            Path to the file that needs to be provided to read()
            if the provided file was indeed a valid file
            Else, None

        Raises
        ------
        NotImplementedError : if this function is called for this or a child
        class that does not provide the ``extension`` keyword argument

        Notes
        -----
        It is recommended to add additional checks as necessary to ensure that
        the translator can indeed read the given file such as by validating the
        headers or similar metadata.
        
Checks whether the provided file can be read by this reader.
This basic function compares the file extension against the
``extension`` keyword argument. If the extension matches, this function
returns True

Parameters

extension : str or iterable of str, Optional. Default = None
File extension for the input file.

Returns

file_path : str
Path to the file that needs to be provided to read()
if the provided file was indeed a valid file
Else, None

Raises

NotImplementedError : if this function is called for this or a child
class that does not provide the ``extension`` keyword argument

Notes

It is recommended to add additional checks as necessary to ensure that
the translator can indeed read the given file such as by validating the
headers or similar metadata.
Checks whether the provided file can be read by this reader . This basic function compares the file extension against the ` ` extension ` ` keyword argument . If the extension matches this function returns True Parameters extension : str or iterable of str Optional . Default = None File extension for the input file . Returns file_path : str Path to the file that needs to be provided to read () if the provided file was indeed a valid file Else None Raises NotImplementedError : if this function is called for this or a child class that does not provide the ` ` extension ` ` keyword argument Notes It is recommended to add additional checks as necessary to ensure that the translator can indeed read the given file such as by validating the headers or similar metadata .
def can_read(self, *args, **kwargs):
        targ_ext = kwargs.get('extension', None)
        if not targ_ext:
            raise NotImplementedError('Either can_read() has not been '
                                      'implemented by this Reader or the '
                                      '"extension" keyword argument was '
                                      'missing')
        if isinstance(targ_ext, (str, unicode)):
            targ_ext = [targ_ext]
        targ_ext = validate_list_of_strings(targ_ext,
                                            parm_name='(keyword argument) '
                                                      '"extension"')
        targ_ext = [item.replace('.', '').lower() for item in targ_ext]
        file_path = os.path.abspath(self._input_file_path)
        extension = os.path.splitext(file_path)[1][1:]
        extension = extension.lower()
        if extension in targ_ext:
            return file_path
        else:
            return None
def can_read ( self , * args , ** kwargs ) : targ_ext = kwargs . get ( 'extension' , None ) if not targ_ext : raise NotImplementedError ( 'Either can_read() has not been ' 'implemented by this Reader or the ' '"extension" keyword argument was ' 'missing' ) if isinstance ( targ_ext , ( str , unicode ) ) : targ_ext = [ targ_ext ] targ_ext = validate_list_of_strings ( targ_ext , parm_name = '(keyword argument) ' '"extension"' ) targ_ext = [ item . replace ( '.' , '' ) . lower ( ) for item in targ_ext ] file_path = os . path . abspath ( self . _input_file_path ) extension = os . path . splitext ( file_path ) [ 1 ] [ 1 : ] extension = extension . lower ( ) if extension in targ_ext : return file_path else : return None
Checks whether the provided file can be read by this reader.
Checks whether the provided file can be read by this reader .
"""
        Checks whether the provided file can be read by this reader.

        This basic function compares the file extension against the
        ``extension`` keyword argument. If the extension matches, this function
        returns True

        Parameters
        ----------
        extension : str or iterable of str, Optional. Default = None
            File extension for the input file.

        Returns
        -------
        file_path : str
            Path to the file that needs to be provided to read()
            if the provided file was indeed a valid file
            Else, None

        Raises
        ------
        NotImplementedError : if this function is called for this or a child
        class that does not provide the ``extension`` keyword argument

        Notes
        -----
        It is recommended to add additional checks as necessary to ensure that
        the translator can indeed read the given file such as by validating the
        headers or similar metadata.
        """ # Get rid of any '.' separators that may be in the list of extensions # Also turn to lower case for case insensitive comparisons # Ensure extension is lower case just like targets above
self