def get_safe_path(in_str):
norm_str = _SAFE_PATH_RE.sub(<EOL>'<STR_LIT:_>', unicodedata.normalize('<STR_LIT>', as_text(in_str)).strip())<EOL>if len(norm_str.strip('<STR_LIT:.>')) == <NUM_LIT:0>:<EOL><INDENT>raise ValueError(in_str)<EOL><DEDENT>return norm_str[:_MAX_PATH_NAME_LEN]<EOL>
Return `in_str` converted to a string that can be be safely used as a
       path (either filename, or directory name).

    >>> print(get_safe_path("hello world, what's up?.txt"))
    hello_world__what_s_up_.txt

    Surrounding spaces are removed, and other "bad characters"
    are replaced with an underscore.
    The function attempts to replace unicode symbols (outside ASCII range)
    with ASCII equivalents (NFKD normalization).
    Everything else is also replaced with underscore.

    :warning: The function just returns a safe string to be used as a path.
              It DOES NOT promise anything about the existence or uniqueness
              of the path in the filesystem! Because of the conversions, many
              input strings will result the same output string, so it is the
              responsibility of the caller to decide how to handle this!

    >>> get_safe_path(' foo/bar.baz') == get_safe_path('foo$bar.baz ')
    True