Skip to main content

Translate OS X / Windows file URLs to directory paths

Project description

https://travis-ci.org/jimr/pathfix.py.png

Using Linux? Tired of receiving emails with links to files of the form X:\some%20path\on\remote%20share\spreadsheet.xls? Then we can help!

pathfix.py takes an unusable path as input and prints a useful one as output. That’s it.

It can handle Windows drive prefixes (if configured), and will also sort out file:// and smb:// prefixes.

Installation

It’s as easy as pip install pathfix.py.

Should work with Python 2.4 - 3.3 and pypy (probably more, but that’s as far as it’s been tested).

There are no requirements unless you’re using Python 2.4-2.6, or 3.0-3.1, in which case (if you’re installing from source) you need argparse:

pip install -r requirements.txt

To make sure it’ll work with your environment, run the tests:

python setup.py test

Configuration

Before using, you need to create a config.ini file that contains the root of your network mounts and any drive mappings (see config.example.ini to get started).

We assume all your network shares are mounted under a common root, with the form:

/<network mount root>/<host name>/<share name>

If you installed from source, you may find it helpful to symlink pathfix.py to /usr/local/bin or somewhere else on your PATH, or you can just python setup.py install and you’ll get the pathfix executable on your path.

If you installed with pip, you should probably make a config.ini somewhere in your home directory and set up an alias, e.g.:

alias pathfix="pathfix --config $HOME/.config/pathfix.ini"

Usage

For example, if you have this in your config.ini:

[main]
network_root = /media/network

[drive_maps]
x = host1:share1
y = host2:share2

Then you can do, for example:

% pathfix "X:\some%20path\on\remote%20share\spreadsheet.xls"
/media/network/host1/share1/some path/on/remote share/spreadsheet.xls

Which you can use in subshells to fix arguments to other applications, for example:

% libreoffice "$(pathfix "X:\some%20path\on\remote%20share\spreadsheet.xls")"

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

pathfix.py-0.3.1.tar.gz (4.0 kB view details)

Uploaded Source

File details

Details for the file pathfix.py-0.3.1.tar.gz.

File metadata

  • Download URL: pathfix.py-0.3.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pathfix.py-0.3.1.tar.gz
Algorithm Hash digest
SHA256 64a5165e80252955e50a39c2798a9b68bddbd5cb2ee4356b10d96b8c3cb80ccd
MD5 04ff439973427c345fe0f8f4e12a2f6a
BLAKE2b-256 89cfc039e335176f13efd6434511930f95af1c58ada094a22d219c4c838956fc

See more details on using hashes here.

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