Skip to main content

Uses os.walk to find and catalogue a given file.

Project description

I do not recommend using this project as it was created for internal use. Due to this it is quite specific in its usecase and quite messy.

As stated in the short description this project simply uses os.walk to traverse a filesystem, starting in the users home directory, looking for a given file. It was created for internal use as there are several of us in the office running python scripts which are located on a onedrive and each time a new machine was initialised onedrive would have wildly different paths. Originally we were just using a simple function at the start of each script which would return the onedrive path but as different parts of the path started changing with new devices I realised this would quickly become an incredibly intricate and inneficient solution so I wrote this to help solve it. Published here for easier distribution around the office.

use:

import pathconf

pathconf.find_path('filename.filetype')

Alternatively you can give it a partial directory.

pathconf.find_path('folder/filename.filetype')

or

pathconf.findpath('foldera/folderb/filename.filetype')

This will create a .file_paths json file in home/.config/pathconf/ if it doesn't already exist and then will search for your file. Once found it will add that file to the pathconf file for quicker access in future runs. If the file does already exist it will lookup your desired file and if it exists in the pathconf.json it will then check that the file exists where stated. If the file exists where the pathconf.json says it does then it will use that file, if the file doesn't exist there or the file doesn't appear in the pathconf.json then it will search for the file and append it to the pathconf.json.

Have now added remove(), reset(), and list_paths().

pathconf.list_paths()

will return a dictionary of all paths in your pathconf.json.

pathconf.reset()

will reset the pathconf.json to a blank file.

pathconf.remove('filename.filetype')

will remove the entry for filename.filetype from the pathconf.json.

Installation:

Easiest way to install is using pip

pip install pathconf

Current issues:

Haven't yet run into but understand that this will always take the first match it finds, if there are files with the same name and type elsewhere in your home directory then it will use them if found first, even if they're not the desired file. Will skip any directory whose name contains 'Deprecated' as an attempt to workaround for our usecase as most duplicate file names will be found in our Deprecated Scripts directory.

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

pathconf-1.0.9.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

pathconf-1.0.9.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file pathconf-1.0.9.1.tar.gz.

File metadata

  • Download URL: pathconf-1.0.9.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for pathconf-1.0.9.1.tar.gz
Algorithm Hash digest
SHA256 3a5b174bbfcc4c545fda0c954d118cbfa77ccd73e05fd0c809c83ef755e8b6b1
MD5 7875404d08a0f653d69f778401dbd9b5
BLAKE2b-256 fbe86768b63df58d0f21e638ef9b1f07e52ceba0099c1a26a227fb40413902a1

See more details on using hashes here.

File details

Details for the file pathconf-1.0.9.1-py3-none-any.whl.

File metadata

  • Download URL: pathconf-1.0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for pathconf-1.0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 572d2120fffc2183a1b502639c7456026007558950a2542d1b4d35745dd8f633
MD5 93c7e8e2ee20f83758d742d1e39efbae
BLAKE2b-256 035520bf3abd8a09c769b9792cc3cec9943953ed9aa1b5f92d19c0baa4bff3cb

See more details on using hashes here.

Supported by

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