Download files from the Cencora secure file transfer site
Project description
Purpose
This Python package can be used to download files from the Cencora (formerly Amerisource) secure file transfer site for ingest into clinical data systems.
Downloads are performed from the web-based secure site located at https://secure.amerisourcebergen.com/. FTP is not supported. (There are many easier ways to automate FTP-based downloads.)
Requirements
- Python 3.10 or newer
Installation
Use pip to install the medberg package.
pip install medberg
Usage
Import the SecureSite class from the medberg module.
from medberg import SecureSite
Initialize a connection to the secure site by providing a username and password.
con = SecureSite(username='yourname', password='yourpassword')
A list of files is automatically downloaded at connection time and stored in the
files variable. Files are represented by objects comprising a name, filesize,
and upload date.
print(con.files)
# [File(name=340B037AM1234567890330.TXT, filesize=self.filesize='1.3MB', date='03/30/2025'), ...]
print(con.files[0].name)
# 340B037AM1234567890330.TXT
print(con.files[0].filesize)
# 1.3MB
print(con.files[0].date)
# datetime.datetime(2025, 3, 30, 8, 13, 58)
Any individual file can be downloaded using the get method of the File class.
Optional parameters can be specified for the save directory (save_dir) and
local filename (save_name). If these are omitted, the file will be saved in
the current working directory using the original filename by default.
con.files[0].get(save_dir='C:\\Users\\yourname\\Downloads\\',
save_name='new_filename.txt')
Files can also be downloaded using the get_file method of the SecureSite
class. In this case, the file to download must be specified in the first
parameter as either an instance of the File class or a string containing the
filename as it appears on the remote site. The optional save_dir and
save_name parameters are again available as with the File.get method.
# Using a File object
file_to_get = con.files[0]
con.get_file(file_to_get)
# Using a string filename
con.get_file('039A_012345678_0101.TXT')
When a file is downloaded using either of the methods above, the return value will be a pathlib Path object pointing to the local file.
Contributing
Pull requests are welcome. Please ensure all code submitted is formatted with Black and tested with pytest. For major changes, please open an issue first to discuss what you would like to change.
When editing the codebase locally, you may install medberg in development mode to use it in REPLs:
pip install -e '.[dev]'
License
This software is licensed under the MIT License.
Disclaimer
This package and its authors are not afiliated, associated, authorized, or endorsed by Cencora, Inc. All names and brands are properties of their respective owners.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file medberg-1.0.0.tar.gz.
File metadata
- Download URL: medberg-1.0.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e98599876c3f1c3bf051e99592f39cefcbc77a0e72e22fb744bb8d3e61db440a
|
|
| MD5 |
4495eaaad51edeb01b4e8f4e189c2682
|
|
| BLAKE2b-256 |
d8ce74e2844db8e62f398a11568f1627aefa9a8ec555917a61ba08ef78a478e6
|
Provenance
The following attestation bundles were made for medberg-1.0.0.tar.gz:
Publisher:
python-publish.yml on eddie-cosma/medberg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
medberg-1.0.0.tar.gz -
Subject digest:
e98599876c3f1c3bf051e99592f39cefcbc77a0e72e22fb744bb8d3e61db440a - Sigstore transparency entry: 190016780
- Sigstore integration time:
-
Permalink:
eddie-cosma/medberg@aa227630f885359412c0b7d08f7c6016a1bce09d -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/eddie-cosma
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@aa227630f885359412c0b7d08f7c6016a1bce09d -
Trigger Event:
release
-
Statement type:
File details
Details for the file medberg-1.0.0-py3-none-any.whl.
File metadata
- Download URL: medberg-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1de6e98321d548251345c2ffd1fbf2171fbddccdbc4d0ca37ad57cdd9b2347f
|
|
| MD5 |
452b5f1d5507cb1a7c35c9c9c80f264a
|
|
| BLAKE2b-256 |
4cc438af0b4d7e783e1ae7e742115ff71f17739e3b729af4c20bc40b2c6f4680
|
Provenance
The following attestation bundles were made for medberg-1.0.0-py3-none-any.whl:
Publisher:
python-publish.yml on eddie-cosma/medberg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
medberg-1.0.0-py3-none-any.whl -
Subject digest:
e1de6e98321d548251345c2ffd1fbf2171fbddccdbc4d0ca37ad57cdd9b2347f - Sigstore transparency entry: 190016781
- Sigstore integration time:
-
Permalink:
eddie-cosma/medberg@aa227630f885359412c0b7d08f7c6016a1bce09d -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/eddie-cosma
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@aa227630f885359412c0b7d08f7c6016a1bce09d -
Trigger Event:
release
-
Statement type: