StringPath for simulating a 'cd' command in a path-like string
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stringpath-1.0.0.tar.gz.
File metadata
- Download URL: stringpath-1.0.0.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69e1f034cea2ee239d8bd20c28a9d3dd78ec391fdc93cd41c18b08c2b6e608e3
|
|
| MD5 |
de014f9c396da03b9dde08235ec92b90
|
|
| BLAKE2b-256 |
b80c27876a0b930c140d2b95e158bb4d3deda857bd5a6c965a10fd23e34c842f
|
File details
Details for the file stringpath-1.0.0-py3-none-any.whl.
File metadata
- Download URL: stringpath-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
727feda8bde0c74a7d785a20bd1742d0e3047e3babb6bc9018d13caf86649639
|
|
| MD5 |
c5586e77e6e648b43cc4203549387d08
|
|
| BLAKE2b-256 |
8e2fa92bcf3206f5ed9fdb63d633f797c6e2e3db1a3f4c2dcda569d8a86942d2
|