Skip to main content

Stringpath for treating a string as a path

About stringpath

stringpath is a python script for simulating the 'cd' command on a string that contains a path.

Please report errors directly to my email: pascalvallaster@gmail.com


Install

Download:

Download with pip:

pip install stringpath

or download the Source Distribution and, or Built Distribution under Download Files.

Install dependencies:

  • Python 3.4^
    • Standard Library

Usage

Basic usage example

from stringpath import change_directory

cwd = r"C:\my/current\path"
cd = r"..\i/want\to\cd/in/here"
new_cwd = change_directory(cwd, cd)

For more usage details see the docs in the functions itself

Use Case example

Imagine your program has to execute sys-commands in different (user-depending) directories with subprocess which will be determined by the user using the command 'cd'. The problem is, you don't want to change the current working directory in order to avoid problems and security threats. This tool allows you to accomplice that.

Example:

import subprocess
import stringpath

command = "dir"
cwd = "C:/MyFiles/MyAppFolder/"
print("'cd' into a different location")
cd = input(cwd + ">")
cwd = stringpath.change_directory(cwd, cd)
subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, cwd=cwd)

Uninstall

pip uninstall stringpath

Release files for stringpath 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stringpath 1.0.0
File Size Uploaded
stringpath-1.0.0.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stringpath 1.0.0
File Interpreter ABI Platform
stringpath-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.0 kB

Release files / stringpath-1.0.0.tar.gz

Download URL stringpath-1.0.0.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
69e1f034cea2ee239d8bd20c28a9d3dd78ec391fdc93cd41c18b08c2b6e608e3
BLAKE2b-256 checksum
How to use checksums
b80c27876a0b930c140d2b95e158bb4d3deda857bd5a6c965a10fd23e34c842f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.11

Release files / stringpath-1.0.0-py3-none-any.whl

Download URL stringpath-1.0.0-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
727feda8bde0c74a7d785a20bd1742d0e3047e3babb6bc9018d13caf86649639
BLAKE2b-256 checksum
How to use checksums
8e2fa92bcf3206f5ed9fdb63d633f797c6e2e3db1a3f4c2dcda569d8a86942d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.11

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page