Allow [\w\d\/\.\-]* to be passed as a file name
167629
public function valid($file_names) {
		$valid = true;
		if(is_array($file_names)) {
			foreach($file_names as $name) {
				if(!$this->_valid($name)) {
					$valid = false;
					break;
				}
			}
		} else {
			$valid = $this->_valid($file_names);
		}
		return $valid;
	}
930936
def _sanitize_params(prefix, suffix, dir):
    """"""
    output_type = _infer_return_type(prefix, suffix, dir)
    if suffix is None:
        suffix = output_type()
    if prefix is None:
        if output_type is str:
            prefix = "tmp"
        else:
            prefix = os.fsencode("tmp")
    if dir is None:
        if output_type is str:
            dir = gettempdir()
        else:
            dir = fs_encode(gettempdir())
    return prefix, suffix, dir, output_type
678980
def write_str2file(pathname, astr):
    """"""
    fname = pathname
    fhandle = open(fname, 'wb')
    fhandle.write(astr)
    fhandle.close()
314136
def pretty_filename(filename):
    ''''''
    try:
        a = os.path.abspath(filename)
        r = os.path.relpath(filename)
    except ValueError:
        # Catch relpath exception. Happens, because it can not produce relative path
        # if wroking directory is on different drive.
        a = r = filename
    return a if '..' in r else r
517552
def rst(filename):
    '''
    
    '''
    content = open(filename).read()
    return re.sub(r'\.\.\s? code-block::\s*(\w|\+)+', '::', content)
554006
def pretty_path(path, _home_re=re.compile('^' + re.escape(os.path.expanduser('~') + os.sep))):
    """"""
    path = format_filename(path)
    path = _home_re.sub('~' + os.sep, path)
    return path
83942
def format_file_path(filepath):
    """"""

    try:
        is_windows_network_mount = WINDOWS_NETWORK_MOUNT_PATTERN.match(filepath)
        filepath = os.path.realpath(os.path.abspath(filepath))
        filepath = re.sub(BACKSLASH_REPLACE_PATTERN, '/', filepath)
        is_windows_drive = WINDOWS_DRIVE_PATTERN.match(filepath)
        if is_windows_drive:
            filepath = filepath.capitalize()
        if is_windows_network_mount:
            # Add back a / to the front, since the previous modifications
            # will have replaced any double slashes with single
            filepath = '/' + filepath
    except:
        pass
    return filepath
89283
def sanitize(filename: str, platform: str=None) -> str:
    
    win_map = {
        # taken from samba Catia module.
        # https://www.samba.org/samba/docs/current/man-html/vfs_catia.8.html
        "\"": "¨",
        "*": "¤",
        "/": "ÿ",
        ":": "÷",
        "<": "«",
        ">": "»",
        "?": "¿",
        "\\": "ÿ",
        "|": "¦",
    }

    posix_map = {
        "/": "-",
    }

    if platform is None:
        platform = sys.platform

    if platform.startswith("win32"):
        replace_map = win_map
    else:
        replace_map = posix_map

    for key, entry in replace_map.items():
        filename = filename.replace(key, entry)

    return filename
8854
function makeFilenameRegex(name) {
  if (!_.isString(name)) {
    throw new TypeError('name parameter must be of type "String"');
  }

  const regexString = `^${name}(?:[.](.+))?.(${fileExtensions.join('|')})$`;
  return new RegExp(regexString);
}
74412
def filename(value):
        '''
        
        '''
        return re.sub('[^a-zA-Z0-9.-_ ]', '', os.path.basename(InputSanitizer.trim(value)))
676821
protected String processFileName(String name) {

        int pos = name.lastIndexOf("/");
        if (pos >= 0) {
            name = name.substring(pos + 1);
        }
        pos = name.lastIndexOf("\\");
        if (pos >= 0) {
            name = name.substring(pos + 1);
        }
        return name;
    }
484811
function getFileNames(path, extension)
{
    var docPath = __dirname + '/' + path;
    var fileNames = [];
    var findPattern = new RegExp("." + extension + "$");
    var replacePattern = new RegExp("." + extension + "$","g");
    fs.readdirSync( docPath ).forEach( function(fileName ) {
        if( fileName.match( findPattern ) ) {
            fileNames.push( fileName.replace( replacePattern, "" ) );
        }
    });

    verbose && console.log('Read "' + extension + '" files from ' + docPath );

    return fileNames;
}
108290
function dirname(p){
  utils.assertString(p, 'path');
  return path.dirname(p.val).replace(/\\/g, '/');
}
751949
def clean_readme(fname):
    """"""
    with codecs.open(fname, 'r', 'utf-8') as f:
        return ''.join(
            re.sub(r':\w+:`([^`]+?)( <[^<>]+>)?`', r'``\1``', line)
            for line in f
            if not (line.startswith('.. currentmodule') or line.startswith('.. toctree'))
        )
445080
def sanitize_filename(filename):
    
    sanitized_filename = re.sub(r'[/\\:*?"<>|]', '-', filename)
    sanitized_filename = sanitized_filename.replace('&', 'and')
    sanitized_filename = sanitized_filename.replace('"', '')
    sanitized_filename = sanitized_filename.replace("'", '')
    sanitized_filename = sanitized_filename.replace("/", '')
    sanitized_filename = sanitized_filename.replace("\\", '')

    # Annoying.
    if sanitized_filename[0] == '.':
        sanitized_filename = u'dot' + sanitized_filename[1:]

    return sanitized_filename
1189805
def _make_command_filename(self, exe):
        """"""

        outfn = os.path.join(self.commons['cmddir'], self.name(),
                             self._mangle_command(exe))

        # check for collisions
        if os.path.exists(outfn):
            inc = 2
            while True:
                newfn = "%s_%d" % (outfn, inc)
                if not os.path.exists(newfn):
                    outfn = newfn
                    break
                inc += 1

        return outfn
148202
def escape_grouped_arguments(s):
    
    if s is None:
        return None

    # Additional escaping for windows paths
    if os.name == "nt":
        s = "{}".format(s.replace("\\", "\\\\"))
    return '"' + s.replace("'", "'\\''") + '"'