Pyomo
  • Getting Started
  • How-To Guides
  • Explanations
  • Reference Guides
    • Topical Reference
    • Library Reference
      • _archive
      • addons
      • common
        • _command
        • _common
        • autoslots
        • backports
        • cmake_builder
        • collections
        • config
        • dependencies
        • deprecation
        • download
        • enums
        • env
        • envvar
        • errors
        • extensions
        • factory
        • fileutils
          • Executable
          • ExecutableData
          • Library
          • PathData
          • PathManager
          • find_dir
          • find_executable
          • find_file
          • find_library
          • find_path
          • import_file
          • register_executable
          • registered_executable
          • this_file
          • this_file_dir
          • to_legal_filename
          • unregister_executable
        • flags
        • formatting
        • gc_manager
        • gsl
        • log
        • modeling
        • multithread
        • numeric_types
        • plugin_base
        • plugins
        • pyomo_typing
        • shutdown
        • sorting
        • tee
        • tempfiles
        • timing
        • unittest
      • contrib
      • core
      • dae
      • dataportal
      • devel
      • duality
      • environ
      • future
      • gdp
      • kernel
      • mpec
      • neos
      • network
      • opt
      • repn
      • scripting
      • solvers
      • tpl
      • unsupported
      • util
      • version
    • Development Principles
    • Accessing preview features
    • Common Warnings/Errors
    • Related Packages
    • Publications
    • Bibliography

Pyomo
  • Reference Guides
  • Library Reference
  • common
  • fileutils
  • to_legal_filename
  • View page source

to_legal_filename

(function from pyomo.common.fileutils)

pyomo.common.fileutils.to_legal_filename(name, universal=False) → str[source]

Convert a string to a legal filename on the current platform.

This converts a candidate file name (not a path) and converts it to a legal file name on the current platform. This includes replacing any unallowable characters (including the path separator) with underscores (_), and on some platforms, enforcing restrictions on the allowable final character.

Parameters:
  • name (str) – The original (desired) file name

  • universal (bool) – If True, this will attempt a form of “universal” standardization that uses the most restrictive set of character translations and rules. Currently, universal=True is equivalent to running the Windows translations.

Previous Next

© Copyright 2008-2026, Sandia National Laboratories.

Built with Sphinx using a theme provided by Read the Docs.