This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

utilities to work with common paths on linux

Project Description

There are some common concepts for application data on linux. Config files, for example, are typically located in /etc/ and in ~/.config/ with the latter taking precedence.

It is a bit awkward in small projects to implement this behavior. So this library is meant to help with that.


Load config:

config_path = lxpath.config('myproject', first=True)
with open(config_path) as fh:

Update existing config:

config_dir = lxpath.config('myproject', can_write=True, first=True)
with open(config_path, 'w') as fh:

Write new cache file:

cache_dir = lxpath.cache(can_write=True, first=True)
cache_path = os.path.join(cache_dir, 'myproject')
with open(cache_path, 'w') as fh:

Get the root of a git repository:

git_path = lxpath.local('.git', first=True)
root_path = os.path.dirname(git_path)

List all icon dirs:

for path in lxpath.share('icons'):


All functions in this module share the same signature:

config(subpath=None, can_read=True, can_write=False, dot_d=False, first=False)


subpath : search for this subpath in all dirs

can_read : remove all paths that the user can not read

can_read : remove all paths that the user can not write

dot_d : if file foo is included, also include all files in foo.d

first : return first match instead of iterator


config() : Search in common config dirs.

share() : Search in common shared data dirs.

cache() : Search in common cache dirs.

local() : Search from local directory upwards.

root() : Search in /.


  • When subpath is set, ~/.{subpath} will be considered in all the functions. So for example config('netrc') may yield ~/.netrc and share('icons') may yield ~/.icons/ (which is desired). But config('icons') will also yield ~/.icons/ and share('netrc') will also yield ~/.netrc (which is not).
Release History

Release History

This version
History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
lxpath-0.0.0.tar.gz (3.1 kB) Copy SHA256 Checksum SHA256 Source Apr 9, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting