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

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

        Parameters
        ----------
        file_path : str
            Path to raw data file

        Returns
        -------
        file_path : str
            Path to the file that needs to be provided to translate()
            if the provided file was indeed a valid file
            Else, None
        """
        file_path = validate_single_string_arg(file_path, 'file_name')

        if not os.path.exists(file_path):
            raise FileNotFoundError(file_path + ' does not exist')

        targ_ext = kwargs.get('extension', None)
        if not targ_ext:
            raise NotImplementedError('Either is_valid_file() has not been '
                                      'implemented by this translator 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(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 translator.

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

        Parameters
        ----------
        file_path : str
            Path to raw data file

        Returns
        -------
        file_path : str
            Path to the file that needs to be provided to translate()
            if the provided file was indeed a valid file
            Else, None
        
Checks whether the provided file can be read by this translator.
This basic function compares the file extension against the "extension"
keyword argument. If the extension matches, this function returns True

Parameters

file_path : str
Path to raw data file

Returns

file_path : str
Path to the file that needs to be provided to translate()
if the provided file was indeed a valid file
Else, None
Checks whether the provided file can be read by this translator . This basic function compares the file extension against the " extension " keyword argument . If the extension matches this function returns True Parameters file_path : str Path to raw data file Returns file_path : str Path to the file that needs to be provided to translate () if the provided file was indeed a valid file Else None
def is_valid_file(file_path, *args, **kwargs):
        file_path = validate_single_string_arg(file_path, 'file_name')
        if not os.path.exists(file_path):
            raise FileNotFoundError(file_path + ' does not exist')
        targ_ext = kwargs.get('extension', None)
        if not targ_ext:
            raise NotImplementedError('Either is_valid_file() has not been '
                                      'implemented by this translator 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(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 is_valid_file ( file_path , * args , ** kwargs ) : file_path = validate_single_string_arg ( file_path , 'file_name' ) if not os . path . exists ( file_path ) : raise FileNotFoundError ( file_path + ' does not exist' ) targ_ext = kwargs . get ( 'extension' , None ) if not targ_ext : raise NotImplementedError ( 'Either is_valid_file() has not been ' 'implemented by this translator 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 ( 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 translator.
Checks whether the provided file can be read by this translator .
"""
        Checks whether the provided file can be read by this translator.

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

        Parameters
        ----------
        file_path : str
            Path to raw data file

        Returns
        -------
        file_path : str
            Path to the file that needs to be provided to translate()
            if the provided file was indeed a valid file
            Else, None
        """ # 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
file_path