Skip to main content

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 The residual keys (others than files, fileset and dialogs) are stored as it in datapak in the others section

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()
others = datapack.getOthers()

Where two examples of datafiles_settings given as a yml file are shown below:

    Example1 - 
    files:
        parent: "C:/folder"
        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:
        images:
            tip: 'provide image file'
            type: 'png'
            set: true           # default value is True
        text:
            tip: 'provide txt file'
            type: 'txt'
            set: false
    mykey1: myvalue1
    mykey2:
       - item1
       - item2

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']}

The "others" section of databank in example 2 would be: others = {'mykey1' : 'myvalue1', 'mykey2': ['item1', 'item2']}

And the dialogs settings pops open a dialog box which 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


Download files

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

Source Distribution

pyDataBank-0.2.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

pyDataBank-0.2-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file pyDataBank-0.2.tar.gz.

File metadata

  • Download URL: pyDataBank-0.2.tar.gz
  • Upload date:
  • Size: 5.3 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

Hashes for pyDataBank-0.2.tar.gz
Algorithm Hash digest
SHA256 accc71ad38ff94b03e5773edd32451b4554298cdb0229425d2083c7727e35321
MD5 a46ca8d26bacc2800a754d09fb8fff6e
BLAKE2b-256 994d56e66a02598036edf06c3d2387d31395f43aa017f7f0ad5361a47f7533ee

See more details on using hashes here.

File details

Details for the file pyDataBank-0.2-py3-none-any.whl.

File metadata

  • Download URL: pyDataBank-0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.7 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

Hashes for pyDataBank-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 daa679fae7457ee26f90c21629d77a052f3a695046537d0dbd9aba4837c5b8b7
MD5 6ee6245015c0a81329d1bc8b620c1f77
BLAKE2b-256 8538512171a875e064590b446cff64141bbfc522e39a1fb56b66cea0552d239d

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