Helper function to find the correct file.

    :type path_name: str
    :param path_name: Path to files to check.
    :type station: str
    :type channel: str

    :returns: list of filenames, str
431258
def _get_station_file(path_name, station, channel, debug=0):
    
    wavfiles = glob.glob(path_name + os.sep + '*')

    out_files = [_check_data(wavfile, station, channel, debug=debug)
                 for wavfile in wavfiles]
    out_files = list(set(out_files))
    return out_files
890021
def find_in_path(name, path):
    ""
    # adapted fom http://code.activestate.com/recipes/52224-find-a-file-given-a-search-path/
    for dir in path.split(os.pathsep):
        binpath = os.path.join(dir, name)
        if os.path.exists(binpath):
            return os.path.abspath(binpath)
    return None
728613
def get_topic_for_path(channel, chan_path_tuple):
    
    assert chan_path_tuple[0] == channel['dirname'], 'Wrong channeldir'
    chan_path_list = list(chan_path_tuple)
    chan_path_list.pop(0)    # skip the channel name

    if len(chan_path_list) == 0:
        return channel

    current = channel
    for subtopic in chan_path_list:
        current = list(filter(lambda d: 'dirname' in d and d['dirname'] == subtopic, current['children']))[0]
    return current
1085244
def generic_filename(path):
    '''
    
    '''

    for sep in common_path_separators:
        if sep in path:
            _, path = path.rsplit(sep, 1)
    return path
1015883
def find_in_paths(name, paths):
    
    for path in paths:
        file_ = osp.join(path, name)
        if osp.exists(file_) and not osp.isdir(file_):
            abs_file = osp.abspath(file_)
            if os.access(file_, os.X_OK):
                return abs_file
474166
def pathNames(self) -> [str]:
        

        return [f.pathName for f in list(self._files.values())]
325043
def find_file(name, directory):
    """"""
    path_bits = directory.split(os.sep)
    for i in range(0, len(path_bits) - 1):
        check_path = path_bits[0:len(path_bits) - i]
        check_file = "%s%s%s" % (os.sep.join(check_path), os.sep, name)
        if os.path.exists(check_file):
            return abspath(check_file)

    return None
1126036
def check_files_exist(filenames):
    ''''''
    files_not_found = [x for x in filenames if not os.path.exists(x)]
    if len(files_not_found):
        for filename in files_not_found:
            print('File not found: "', filename, '"', sep='', file=sys.stderr)
        raise Error('File(s) not found. Cannot continue')
183834
def which(self, fname):
        """"""
        for pe in os.environ['PATH'].split(os.pathsep):
            checkname = os.path.join(pe, fname)
            if os.access(checkname, os.X_OK) and not os.path.isdir(checkname):
                return checkname
        return None
1093443
def _check_portname(name):
    '''
    
    '''
    if not isinstance(name, string_types) or '/' not in name:
        raise SaltInvocationError(
            'Invalid port name \'{0}\' (category required)'.format(name)
        )

    path = os.path.join('/usr/ports', name)
    if not os.path.isdir(path):
        raise SaltInvocationError('Path \'{0}\' does not exist'.format(path))

    return path
262986
def filename(self) -> str:
        
        if self._new_path is not None and str(self._new_path) != "/dev/null":
            path = self._new_path
        else:
            path = self._old_path

        return path.name
342303
def has_file(self, name: str):
        '''
        
        '''
        return os.path.isfile(self._path / name)
365377
def _get_file_name(file_path):
    

    file_name = basename(file_path)

    utf8_file_name = bytearray(file_name, "utf8")
    utf8_file_name.append(0)

    return utf8_file_name
1036702
def check_file_paths(self, *args):
        
        for path in enumerate(args):
            path = path[1]
            if path is not None:
                try:
                    self.check_file_path(path)
                except OSError as ex:
                    logger.warn(ex)
                    raise
        return args
918985
def ls(name, path):
    
    with Session() as session:
        try:
            print_wait('Retrieving list of files in "{}"...'.format(path))
            result = session.VFolder(name).list_files(path)
            if 'error_msg' in result and result['error_msg']:
                print_fail(result['error_msg'])
                return
            files = json.loads(result['files'])
            table = []
            headers = ['file name', 'size', 'modified', 'mode']
            for file in files:
                mdt = datetime.fromtimestamp(file['mtime'])
                mtime = mdt.strftime('%b %d %Y %H:%M:%S')
                row = [file['filename'], file['size'], mtime, file['mode']]
                table.append(row)
            print_done('Retrived.')
            print(tabulate(table, headers=headers))
        except Exception as e:
            print_error(e)
679991
def _search_path(self, directory_name, filename):
        """"""
        full_path = path.join(directory_name, filename)
        if path.exists(full_path):
            return full_path

        # Could not find the requested file in any of the directories
        return None
165596
def find(name, version = nil)
      name     = Pathname.new(name)
      stem     = name.basename
      version  = version && version.strip != '' ? version.strip : nil
      ext      = '.js'
      possible_paths = if version
        [
          /#{stem}-#{version}\/#{name}#{ext}$/,
         /#{name}-#{version}#{ext}$/
        ]
      else
        [
          /#{name}#{ext}/,
          /#{name}-[\d\w\.\-]+#{ext}/
        ]
      end
      final = false
      each_file_in_index(ext) do |filename|
        possible_paths.each do |p|
          if File.file?(filename) && p.match(filename)
            final = Pathname.new(filename).expand_path
            block_given? ? yield(final) : break
          end
        end
        break if final && !block_given?
      end
      final
    end