<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def scan_path(self, path, result = None):
 """Determines which valid fortran files reside in the base path. :arg path: the path to the folder to list f90 files in. :arg result: an optional dictionary to add results to in addition to populating the private member dictionary of the parser. """

        files = []
        
        #Find all the files in the directory
        for (dirpath, dirnames, filenames) in self.tramp.walk(path):
            files.extend(filenames)
            break

        #Check if the .fpyignore file exists in the folder.
        patterns = [".#*"]
        if ".fpyignore" in files:
            for line in self.tramp.read(os.path.join(path, ".fpyignore")).split('\n'):
                sline = line.strip()
                if len(sline) > 0 and sline[0] != '#':
                    patterns.append(sline)
                    
        #Filter them to find the fortran code files
        from fnmatch import fnmatch
        for fname in files:
            if fnmatch(fname, "*.f90"):
                if all([not fnmatch(fname, p) for p in patterns]):
                    self._pathfiles[fname.lower()] = os.path.join(path, fname)
                    if result is not None:
                        result[fname.lower()] = os.path.join(path, fname)