module to manage a bunch of resource files using regex or dialogs
Project description
pyDataIP
Import resource files by selecting them one by one or in a batch with regex or with open dialog window Associate these files or filesets to a key for an easy call
An example of use of both classes is shown below:
resources = DataFiles(datafiles_settings)
datapack = resources.generateDataPack()
files_as_dict = datapack.getFileDict()
fileset_as_dict = datapack.getFilesetDict()
all_files_as_list = datapack.getFileList()
Where two examples of datafiles_settings given as a yml file are shown below:
Example1
files:
parent:
tip: 'select your jpg file'
type: 'jpg"
depth: -1
caseSensitive: true
file1: 'fi.*_1\.txt'
file2: 'file2'
fileset:
parent: "C:/folder2"
depth: 0
caseSensitive: true
texts_set: '.*\.txt'
images_set2: .*\.(jpg|png|tif|tiff)
Example2
dialogs:
image:
tip: 'provide image file'
type: 'png'
set: true # default value is True
text:
tip: 'provide txt file'
type: 'txt'
set: false
The resulting loaded resources due to the "files" section could be:
files_as_dict = {'file1': 'path/to/file_1.txt', 'file2': 'path/to/myfile2.txt}
fileset_as_dict = {'texts_set': ['mydoc.txt'], 'images_set2': ['image1.png', 'image2.jpg']}
And the dialogs settings pops open a dialog box xhich creates a fileset for 'image' and a file dictionary for 'text'
DataFiles class
The DataFiles class manages resource files thanks to 2 dictionaries (files and fileset), one is a key/value per file, the other one is a key/value per file set (a group of files)
The way resource files are retrieved is based on regex. It uses Finder class of pyFileFinder module to do so. It is also possible to request the pop up of an open dialog box to select files.
generateDataPack method returns a DataPack object. DataPack will be discussed in the next section.
See more example in the test class
DataPack class
The DataPack class is a container for 2 types of data: file paths and fileset paths. It manages 2 dictionaries. The first one is {name: path} with name as a short name for the file and path the file path The second one is {name: [paths]} with name as a short name for the fileset and [paths] the list of file paths Then it allows calling files by their shortname or get a list of all files referenced in the 2 dictionaries.
It offers convenient methods to
- add files or filesets with or without a short name for these resources. A unique short name is always given to added resources.
- get files, fileset or the list of all files either contained in files or in fileset
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
File details
Details for the file pyDataBank-0.1.tar.gz
.
File metadata
- Download URL: pyDataBank-0.1.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.6.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35d9fb67a1829eaec02962eab6d7b2841a50e05512c5e0b10b5618addaac741c |
|
MD5 | 60a12d7227198a4c542080fe37416f3b |
|
BLAKE2b-256 | 9e1b9f62762dc061c0e5b2cafb4fe762acf1a96b8d7df94281b7d25312d1d3fb |
File details
Details for the file pyDataBank-0.1-py3-none-any.whl
.
File metadata
- Download URL: pyDataBank-0.1-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.6.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | db47baffd7a431403a95286b4cccb80816cb14f75f7126b5580c990795447a2c |
|
MD5 | 1cc77c92a967a7862e4a6738b33a2b10 |
|
BLAKE2b-256 | b20794905a6b4e63b801792cd021397da11916c653cfd32a29f4d3a9186e5622 |