Skip to main content

Definitive Python wrapper for Windows System Path

Project description

winsyspath

Definitive Python wrapper for Windows System Path

Compatibility

  • Python 2.7.x
  • Python 3.x and newer

Example

import winsyspath

# Directory to add in the System Path
path = 'C:\\'

# Init System Path wrapper and read its actual value
syspath_wrapper = winsyspath.WinSysPath()

# Try to add a path into System path
try:
    if syspath_wrapper.add(path):
        print("The path "{}" is correctly added to the System Path".format(path))
    else:
        print("The path "{}" is already in System Path, so cannot be added".format(path))
except (EnvironmentError, WindowsError, OSError, ValueError) as ex:
    print("Error -> {}".format(str(ex)))

# Reload System path value (needed only if it is modified outside python)
syspath_wrapper.reload()

# Print System Path value as a list
print(syspath_wrapper.get())

# Print System Path value as a string
print(syspath_wrapper.get_str())

# Try to remove a path from System path
try:
    if syspath_wrapper.remove(path):
        print("The path "{}" is correctly removed from System Path".format(path))
    else:
        print("The path "{}" is not in System Path, so cannot be removed".format(path))
except (EnvironmentError, WindowsError, OSError, ValueError) as ex:
    print("Error -> {}".format(str(ex)))

Sources

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for winsyspath, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size winsyspath-0.1.0-py2.py3-none-any.whl (6.1 kB) File type Wheel Python version py2.py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page