Skip to main content

A comprehensive toolkit for handling UNC paths, network drives, and substituted drives

Project description

UNCtools

A comprehensive toolkit for handling UNC paths, network drives, and substituted drives across different environments.

Features

  • Convert between UNC paths (\\server\share) and local drive paths (Z:\)
  • Detect UNC paths, network drives, and substituted drives
  • Handle Windows security zones for improved UNC path access
  • Provide high-level file operations that work seamlessly with UNC paths
  • Cross-platform compatibility with graceful degradation

Installation

Standard Installation

pip install unctools

With Windows-specific Support

pip install unctools[windows]

Development Mode

For development and testing:

git clone https://github.com/yourusername/unctools.git
cd unctools
pip install -e .[dev]

Usage

Basic Path Conversion

from unctools import convert_to_local, convert_to_unc

# Convert UNC path to local drive path
local_path = convert_to_local("\\\\server\\share\\folder\\file.txt")
# Result (if mapped): "Z:\\folder\\file.txt"

# Convert local drive path back to UNC
unc_path = convert_to_unc("Z:\\folder\\file.txt")
# Result: "\\\\server\\share\\folder\\file.txt"

Path Detection

from unctools import is_unc_path, is_network_drive, is_subst_drive, get_path_type

# Check if a path is a UNC path
if is_unc_path("\\\\server\\share\\file.txt"):
    print("This is a UNC path")

# Check if a drive is a network drive
if is_network_drive("Z:"):
    print("Z: is a network drive")

# Get the type of a path
path_type = get_path_type("C:\\Users\\")
# Result: "local", "network", "subst", "unc", etc.

Safe File Operations

from unctools import safe_open, safe_copy, batch_convert

# Open a file, handling UNC paths automatically
with safe_open("\\\\server\\share\\file.txt", "r") as f:
    content = f.read()

# Copy a file, handling path conversions
safe_copy("\\\\server\\share\\file.txt", "local_copy.txt")

# Convert multiple paths at once
paths = ["\\\\server\\share\\file1.txt", "\\\\server\\share\\file2.txt"]
converted = batch_convert(paths, to_unc=False)

Windows Security Zones

from unctools.windows import fix_security_zone, add_to_intranet_zone

# Fix security zone issues for a server
fix_security_zone("server")

# Add a server to the Local Intranet zone
add_to_intranet_zone("server")

Network Drive Management

from unctools.windows import create_network_mapping, remove_network_mapping

# Create a network drive mapping
success, drive = create_network_mapping("\\\\server\\share", "Z:")

# Remove a network drive mapping
remove_network_mapping("Z:")

Platform Compatibility

UNCtools is designed to work across various platforms:

  • Windows: Full functionality including security zones and network drive management
  • Linux/macOS: Basic path conversion and detection, with graceful degradation for Windows-specific features

Development

Running Tests

pytest

Code Style

black unctools
flake8 unctools

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Project details


Download files

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

Source Distribution

unctools-0.2.0.tar.gz (62.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unctools-0.2.0-py3-none-any.whl (36.5 kB view details)

Uploaded Python 3

File details

Details for the file unctools-0.2.0.tar.gz.

File metadata

  • Download URL: unctools-0.2.0.tar.gz
  • Upload date:
  • Size: 62.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for unctools-0.2.0.tar.gz
Algorithm Hash digest
SHA256 891ac7721a21628ff6f24861b13b3b2d223f05d5290732c9fc29c8dc720d9da4
MD5 b8c0c74d258a5de708660c0124ced1f6
BLAKE2b-256 51824605361fc27a98533abb924d19e60e89b1dd372d3417ff15fc6914331bfe

See more details on using hashes here.

Provenance

The following attestation bundles were made for unctools-0.2.0.tar.gz:

Publisher: release.yml on DazzleLib/UNCtools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file unctools-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: unctools-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 36.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for unctools-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 989615f9e7b6107ce032b57c74fc5641c425d9ff0ba113c2e90c70b19a6d83bd
MD5 eabf43cfb5b9450ff0b0b5f801f748de
BLAKE2b-256 982f5abe4e19a910840dd3c50e278c0b1e0337294e31476ef9af54ce6220b6c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for unctools-0.2.0-py3-none-any.whl:

Publisher: release.yml on DazzleLib/UNCtools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page