file_store
This is the oldest code in Antelope (and among my first ever pieces of python code). Please don't judge.
Written to access ILCD and ecospold archives in either zipped or unzipped or 7z format and GaBi web databases equally
Unfortunately, the 7z format has some kind of bug where time per read grows linearly with the number of reads. I should report it.
FileStore
Bases: object
A strictly local archive of files to be used as a repository
__init__(path, internal_prefix=None, query_string=None, cache=True)
Create a FileStore object from a path. Basically encapsulates the compression algorithm and presents a common interface to client code: self.listfiles() self.countfiles() self.readfile(filename)
writing providers is not presently supported.
By default remote archives create a local cache to store downloaded files- this cache is mounted as an ordinary archive and is checked first when readfile() is called. You can force a re-download by specifying .readfile(..., force_download=True)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
|
required | |
internal_prefix |
if present, silently absorb / conceal the specified prefix (prepend to requests, trim from responses). |
None
|
|
query_string |
for remote repositories, append the supplied string after '?' in the URL |
None
|
|
cache |
(True) for remote repositories, cache downloaded files locally and use first |
True
|
Returns:
Type | Description |
---|---|
an archive object |
listfiles(in_prefix='')
generate files in the archive, removing internal prefix, optionally filtering to specified prefix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
in_prefix |
optional prefix to limit |
''
|
Returns:
Type | Description |
---|---|
|
readfile(fname, force_download=False)
Have to decide what this does. I think it should return the raw data- since there's no way to get a pointer to a file in a generic archive
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fname |
|
required | |
force_download |
for remote caching archives: |
False
|
Returns:
Type | Description |
---|---|
|