blomp-api


Nameblomp-api JSON
Version 1.0.4 PyPI version JSON
download
home_pagehttps://pypi.org/project/blomp-api
SummaryA unofficial Python API client to the Blomp cloud.
upload_time2024-03-03 15:55:43
maintainer
docs_urlNone
authorIzak76
requires_python>=3.8
licenseMIT
keywords python web api blomp rest
VCS
bugtrack_url
requirements requests requests_toolbelt
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # blomp-api

[![Static Badge](https://img.shields.io/badge/GitHub-Source_code-blue?logo=github&logoColor=white)](https://github.com/Izak76/blomp-api)
[![PyPI - License](https://img.shields.io/pypi/l/blomp-api)](https://github.com/Izak76/blomp-api/blob/main/LICENSE)
[![PyPI - Version](https://img.shields.io/pypi/v/blomp-api)](https://pypi.org/project/blomp-api)
![PyPI - Status](https://img.shields.io/pypi/status/blomp-api)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/blomp-api?logo=python&logoColor=white)
[![Pepy Total Downlods](https://img.shields.io/pepy/dt/blomp-api)](https://www.pepy.tech/projects/blomp-api)

A unofficial Python API client to the [Blomp cloud](https://www.blomp.com).

## Table of contents
- [Instalation](#instalation)
- [Examples](#examples)
    - [Getting started with the API](#getting-started-with-the-api)
    - [Example directory structure for the next examples](#example-directory-structure-for-the-next-examples)
    - [Access files and folders](#access-files-and-folders)
    - [Downloading a file and getting download progress](#downloading-a-file-and-getting-download-progress)
    - [Uploading a file and getting upload progress](#uploading-a-file-and-getting-upload-progress)
    - [Other operations with folders](#other-operations-with-folders)
        - [Create a new folder](#create-a-new-folder)
        - [Renaming a folder](#renaming-a-folder)
        - [Cutting or copying files and folders](#cutting-or-copying-files-and-folders)
        - [Deleting files and folders](#deleting-files-and-folders)
    - [Other operations with files](#other-operations-with-files)
        - [Renaming a file](#renaming-a-file)
        - [Sharing a file](#sharing-a-file)
- [Other information](#other-information)
- [License](#license)
- [Source Code](#source-code)
- [Changelog](#changelog)

## Instalation
Blomp API can be installed with pip:
```sh
pip install blomp-api
```

## Examples

### Getting started with the API
```python
from blomp_api import Blomp

# Log in to your Blomp account
blomp = Blomp("youremail@example.com", "yourpassword")

# Get your cloud root directory
root = blomp.get_root_directory()
```

### Example directory structure for the next examples
```
(root directory)
├── folder1/
│   ├── file1.ext
│   └── file2.ext
├── folder2/
│   ├── folder3/
│   │   └── file3.ext
│   └── file4.ext
├── file5.txt
└── file6.ext
```

### Access files and folders
```python
# Getting a folder using the get_folder_by_name method
folder1 = root.get_folder_by_name("folder1")

# Getting a file using the get_file_by_name method
file5 = root.get_file_by_name("file5.ext")

# Getting a file from a tuple with all files in the folder
# root.files -> (File(file5.ext), File(file6.ext))
file6 = root.files[-1]

# Getting a folder from a tuple with all subfolders in the folder
# root.subfolders -> (Folder(folder1), Folder(folder2))
folder2 = root.subfolders[1]

# All folders are iterable
# tuple(folder) is equivalent to folder.subfolders+folder.files
# tuple(folder2) -> (Folder(folder3), File(file4.ext))
folder3 = tuple(folder2)[0]

# All folders are subscriptable
# folder[i] is equivalent to tuple(folder)[i]
file1 = folder1[0]
file4 = folder2[1]
```

### Downloading a file and getting download progress
```python
# NOTE: All folder and file variables are the same as in previous examples

# Specifying a directory to save the file
# The following file will be saved as "/path/to/save/file1.ext"
thread1, monitor1 = file1.download("/path/to/save")

# Waiting for file1.ext to complete download
thread1.join()

# Specifying a directory and file name
# The following file will be saved as "/path/to/save/f4.ext"
# If a directory is not specified, then the file will be saved
# in the same directory where the program is running.
# This time we will let the following download occur in parallel
file4.download("/path/to/save/f4.ext")

# Specifying an open file object
with open("file5.ext", "wb") as f5:
    thread5 = file5.download(f5)[0]
    thread5.join()

# Nothing specified
# The following file will be saved as "file6.ext"
thread6, monitor6 = file6.download()

# Monitoring "file6.ext" download progress
while thread6.is_alive():
    loaded = monitor6.loaded
    total = monitor6.total
    progress = int(monitor6.progress)*100

    print(f"\r{loaded} of {total} bytes downloaded ({progress}%)")
```

### Uploading a file and getting upload progress
```python
# NOTE: All folder and file variables are the same as in previous examples

# Uploading a file to root directory
# The file will be saved in the root directory as "file7.ext"
thread7, monitor7 = root.upload("/path/to/file/file7.ext")

# Monitoring "file7.ext" upload progress
while thread7.is_alive():
    loaded = monitor7.loaded
    total = monitor7.total
    progress = int(monitor7.progress)*100

    print(f"\r{loaded} of {total} bytes uploaded ({progress}%)")

# Uploading a file from a file object to "folder1"
# The file will be saved in the folder1 as file8.ext
with open("/path/to/file/file8.ext", "rb") as f8:
    thread8, monitor8 = folder1.upload(f8)
    thread8.join()

# Upload specifying file name
folder3.upload("path/to/file/file9_1.ext", file_name="file9.ext")[0].join()

# Uploading a file when there is already another file
# with the same name in folder.
# If a file of the same name is found and the "replace_if_exists"
# attribute is False (default), FileExistsError is raised.
folder3.upload("path/to/file/file9.ext", replace_if_exists=True)
```

### Other operations with folders
All folder and file variables in the following examples are the same as in the previous examples.

#### Create a new folder
```python
# Creating a new folder in "folder3" com nome "folder4"
folder3.create_folder("folder4")
```

#### Renaming a folder
```python
# Renaming "folder4" to "folder5"
folder4 = folder3.get_folder_by_name("folder4")
folder4.safe_rename("folder5")
print(folder4.name) # Will be printed "folder5"
```

#### Cutting or copying files and folders
```python
folder5 = folder3.get_folder_by_name("folder5")
file7 = root.get_file_by_name("file7.ext")

# The following operations apply to both files and folders

# Copying a file to a folder
folder5.paste(file7)

# Cutting a folder to another folder
folder1.paste(folder5, cut=True)

folder1.reload()
folder5.reload()
```

#### Deleting files and folders
```python
# Deleting a file
file8 = folder1.get_file_by_name("file8.ext")
folder1.delete(file8)

# Deleting a folder
folder1.delete(folder5)

# Deleting a file by name (also works with folder names)
folder3.delete("file9.ext")

folder1.reload()
folder3.reload()
```

### Other operations with files
All folder and file variables in the following examples are the same as in the previous examples.

#### Renaming a file
```python
file6.rename("file66.ext")
print(file6.name) # Will be printed "file66.ext"
```

#### Sharing a file
```python
# Enabling sharing of "file1.ext" and getting the link
file1_link = file1.share()

# Enabling sharing of "file2.ext" and sending the link to an email list
file2 = folder1.get_file_by_name("file2.ext")
file2_link = file2.share(["email1@example.com", "email2@example.com"])

# Disabling sharing of "file1.ext"
file1.share_switch_off()

# Enabling sharing of "file1.ext"
file1.share_switch_on()
```

## Other information
For more information, type into your Python shell:
```python
help(<blomp_object>)
```
Where `<blomp_object>` can be:
- A `Blomp` instance
    - Example:
        ```python
        from blomp import Blomp

        blomp = Blomp("youremail@example.com", "yourpassword")
        help(blomp)
        ```
- A `Folder`object
    - Example:
        ```python
        root = blomp.get_root_directory()
        help(root)
        ```
- A `File` object
    - Example:
        ```python
        file = root.get_file_by_name("<file_name>")
        help(file)
        ```

## License
This package is released under the MIT License. See the [LICENSE](https://github.com/Izak76/blomp-api/blob/main/LICENSE) file for details.

## Source Code
Source code is available on [GitHub](https://github.com/Izak76/blomp-api).

## Changelog
Changelog is available on [GitHub](https://github.com/Izak76/blomp-api/blob/main/CHANGELOG).

            

Raw data

            {
    "_id": null,
    "home_page": "https://pypi.org/project/blomp-api",
    "name": "blomp-api",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "Python,Web API,Blomp,REST",
    "author": "Izak76",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/a3/30/569c373cf2f76c4e9f4db338062883fdb7ac9f8e58219c00ae7a514c54ab/blomp_api-1.0.4.tar.gz",
    "platform": null,
    "description": "# blomp-api\r\n\r\n[![Static Badge](https://img.shields.io/badge/GitHub-Source_code-blue?logo=github&logoColor=white)](https://github.com/Izak76/blomp-api)\r\n[![PyPI - License](https://img.shields.io/pypi/l/blomp-api)](https://github.com/Izak76/blomp-api/blob/main/LICENSE)\r\n[![PyPI - Version](https://img.shields.io/pypi/v/blomp-api)](https://pypi.org/project/blomp-api)\r\n![PyPI - Status](https://img.shields.io/pypi/status/blomp-api)\r\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/blomp-api?logo=python&logoColor=white)\r\n[![Pepy Total Downlods](https://img.shields.io/pepy/dt/blomp-api)](https://www.pepy.tech/projects/blomp-api)\r\n\r\nA unofficial Python API client to the [Blomp cloud](https://www.blomp.com).\r\n\r\n## Table of contents\r\n- [Instalation](#instalation)\r\n- [Examples](#examples)\r\n    - [Getting started with the API](#getting-started-with-the-api)\r\n    - [Example directory structure for the next examples](#example-directory-structure-for-the-next-examples)\r\n    - [Access files and folders](#access-files-and-folders)\r\n    - [Downloading a file and getting download progress](#downloading-a-file-and-getting-download-progress)\r\n    - [Uploading a file and getting upload progress](#uploading-a-file-and-getting-upload-progress)\r\n    - [Other operations with folders](#other-operations-with-folders)\r\n        - [Create a new folder](#create-a-new-folder)\r\n        - [Renaming a folder](#renaming-a-folder)\r\n        - [Cutting or copying files and folders](#cutting-or-copying-files-and-folders)\r\n        - [Deleting files and folders](#deleting-files-and-folders)\r\n    - [Other operations with files](#other-operations-with-files)\r\n        - [Renaming a file](#renaming-a-file)\r\n        - [Sharing a file](#sharing-a-file)\r\n- [Other information](#other-information)\r\n- [License](#license)\r\n- [Source Code](#source-code)\r\n- [Changelog](#changelog)\r\n\r\n## Instalation\r\nBlomp API can be installed with pip:\r\n```sh\r\npip install blomp-api\r\n```\r\n\r\n## Examples\r\n\r\n### Getting started with the API\r\n```python\r\nfrom blomp_api import Blomp\r\n\r\n# Log in to your Blomp account\r\nblomp = Blomp(\"youremail@example.com\", \"yourpassword\")\r\n\r\n# Get your cloud root directory\r\nroot = blomp.get_root_directory()\r\n```\r\n\r\n### Example directory structure for the next examples\r\n```\r\n(root directory)\r\n\u251c\u2500\u2500 folder1/\r\n\u2502   \u251c\u2500\u2500 file1.ext\r\n\u2502   \u2514\u2500\u2500 file2.ext\r\n\u251c\u2500\u2500 folder2/\r\n\u2502   \u251c\u2500\u2500 folder3/\r\n\u2502   \u2502   \u2514\u2500\u2500 file3.ext\r\n\u2502   \u2514\u2500\u2500 file4.ext\r\n\u251c\u2500\u2500 file5.txt\r\n\u2514\u2500\u2500 file6.ext\r\n```\r\n\r\n### Access files and folders\r\n```python\r\n# Getting a folder using the get_folder_by_name method\r\nfolder1 = root.get_folder_by_name(\"folder1\")\r\n\r\n# Getting a file using the get_file_by_name method\r\nfile5 = root.get_file_by_name(\"file5.ext\")\r\n\r\n# Getting a file from a tuple with all files in the folder\r\n# root.files -> (File(file5.ext), File(file6.ext))\r\nfile6 = root.files[-1]\r\n\r\n# Getting a folder from a tuple with all subfolders in the folder\r\n# root.subfolders -> (Folder(folder1), Folder(folder2))\r\nfolder2 = root.subfolders[1]\r\n\r\n# All folders are iterable\r\n# tuple(folder) is equivalent to folder.subfolders+folder.files\r\n# tuple(folder2) -> (Folder(folder3), File(file4.ext))\r\nfolder3 = tuple(folder2)[0]\r\n\r\n# All folders are subscriptable\r\n# folder[i] is equivalent to tuple(folder)[i]\r\nfile1 = folder1[0]\r\nfile4 = folder2[1]\r\n```\r\n\r\n### Downloading a file and getting download progress\r\n```python\r\n# NOTE: All folder and file variables are the same as in previous examples\r\n\r\n# Specifying a directory to save the file\r\n# The following file will be saved as \"/path/to/save/file1.ext\"\r\nthread1, monitor1 = file1.download(\"/path/to/save\")\r\n\r\n# Waiting for file1.ext to complete download\r\nthread1.join()\r\n\r\n# Specifying a directory and file name\r\n# The following file will be saved as \"/path/to/save/f4.ext\"\r\n# If a directory is not specified, then the file will be saved\r\n# in the same directory where the program is running.\r\n# This time we will let the following download occur in parallel\r\nfile4.download(\"/path/to/save/f4.ext\")\r\n\r\n# Specifying an open file object\r\nwith open(\"file5.ext\", \"wb\") as f5:\r\n    thread5 = file5.download(f5)[0]\r\n    thread5.join()\r\n\r\n# Nothing specified\r\n# The following file will be saved as \"file6.ext\"\r\nthread6, monitor6 = file6.download()\r\n\r\n# Monitoring \"file6.ext\" download progress\r\nwhile thread6.is_alive():\r\n    loaded = monitor6.loaded\r\n    total = monitor6.total\r\n    progress = int(monitor6.progress)*100\r\n\r\n    print(f\"\\r{loaded} of {total} bytes downloaded ({progress}%)\")\r\n```\r\n\r\n### Uploading a file and getting upload progress\r\n```python\r\n# NOTE: All folder and file variables are the same as in previous examples\r\n\r\n# Uploading a file to root directory\r\n# The file will be saved in the root directory as \"file7.ext\"\r\nthread7, monitor7 = root.upload(\"/path/to/file/file7.ext\")\r\n\r\n# Monitoring \"file7.ext\" upload progress\r\nwhile thread7.is_alive():\r\n    loaded = monitor7.loaded\r\n    total = monitor7.total\r\n    progress = int(monitor7.progress)*100\r\n\r\n    print(f\"\\r{loaded} of {total} bytes uploaded ({progress}%)\")\r\n\r\n# Uploading a file from a file object to \"folder1\"\r\n# The file will be saved in the folder1 as file8.ext\r\nwith open(\"/path/to/file/file8.ext\", \"rb\") as f8:\r\n    thread8, monitor8 = folder1.upload(f8)\r\n    thread8.join()\r\n\r\n# Upload specifying file name\r\nfolder3.upload(\"path/to/file/file9_1.ext\", file_name=\"file9.ext\")[0].join()\r\n\r\n# Uploading a file when there is already another file\r\n# with the same name in folder.\r\n# If a file of the same name is found and the \"replace_if_exists\"\r\n# attribute is False (default), FileExistsError is raised.\r\nfolder3.upload(\"path/to/file/file9.ext\", replace_if_exists=True)\r\n```\r\n\r\n### Other operations with folders\r\nAll folder and file variables in the following examples are the same as in the previous examples.\r\n\r\n#### Create a new folder\r\n```python\r\n# Creating a new folder in \"folder3\" com nome \"folder4\"\r\nfolder3.create_folder(\"folder4\")\r\n```\r\n\r\n#### Renaming a folder\r\n```python\r\n# Renaming \"folder4\" to \"folder5\"\r\nfolder4 = folder3.get_folder_by_name(\"folder4\")\r\nfolder4.safe_rename(\"folder5\")\r\nprint(folder4.name) # Will be printed \"folder5\"\r\n```\r\n\r\n#### Cutting or copying files and folders\r\n```python\r\nfolder5 = folder3.get_folder_by_name(\"folder5\")\r\nfile7 = root.get_file_by_name(\"file7.ext\")\r\n\r\n# The following operations apply to both files and folders\r\n\r\n# Copying a file to a folder\r\nfolder5.paste(file7)\r\n\r\n# Cutting a folder to another folder\r\nfolder1.paste(folder5, cut=True)\r\n\r\nfolder1.reload()\r\nfolder5.reload()\r\n```\r\n\r\n#### Deleting files and folders\r\n```python\r\n# Deleting a file\r\nfile8 = folder1.get_file_by_name(\"file8.ext\")\r\nfolder1.delete(file8)\r\n\r\n# Deleting a folder\r\nfolder1.delete(folder5)\r\n\r\n# Deleting a file by name (also works with folder names)\r\nfolder3.delete(\"file9.ext\")\r\n\r\nfolder1.reload()\r\nfolder3.reload()\r\n```\r\n\r\n### Other operations with files\r\nAll folder and file variables in the following examples are the same as in the previous examples.\r\n\r\n#### Renaming a file\r\n```python\r\nfile6.rename(\"file66.ext\")\r\nprint(file6.name) # Will be printed \"file66.ext\"\r\n```\r\n\r\n#### Sharing a file\r\n```python\r\n# Enabling sharing of \"file1.ext\" and getting the link\r\nfile1_link = file1.share()\r\n\r\n# Enabling sharing of \"file2.ext\" and sending the link to an email list\r\nfile2 = folder1.get_file_by_name(\"file2.ext\")\r\nfile2_link = file2.share([\"email1@example.com\", \"email2@example.com\"])\r\n\r\n# Disabling sharing of \"file1.ext\"\r\nfile1.share_switch_off()\r\n\r\n# Enabling sharing of \"file1.ext\"\r\nfile1.share_switch_on()\r\n```\r\n\r\n## Other information\r\nFor more information, type into your Python shell:\r\n```python\r\nhelp(<blomp_object>)\r\n```\r\nWhere `<blomp_object>` can be:\r\n- A `Blomp` instance\r\n    - Example:\r\n        ```python\r\n        from blomp import Blomp\r\n\r\n        blomp = Blomp(\"youremail@example.com\", \"yourpassword\")\r\n        help(blomp)\r\n        ```\r\n- A `Folder`object\r\n    - Example:\r\n        ```python\r\n        root = blomp.get_root_directory()\r\n        help(root)\r\n        ```\r\n- A `File` object\r\n    - Example:\r\n        ```python\r\n        file = root.get_file_by_name(\"<file_name>\")\r\n        help(file)\r\n        ```\r\n\r\n## License\r\nThis package is released under the MIT License. See the [LICENSE](https://github.com/Izak76/blomp-api/blob/main/LICENSE) file for details.\r\n\r\n## Source Code\r\nSource code is available on [GitHub](https://github.com/Izak76/blomp-api).\r\n\r\n## Changelog\r\nChangelog is available on [GitHub](https://github.com/Izak76/blomp-api/blob/main/CHANGELOG).\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A unofficial Python API client to the Blomp cloud.",
    "version": "1.0.4",
    "project_urls": {
        "Bug Reports": "https://github.com/Izak76/blomp-api/issues",
        "Changes": "https://github.com/Izak76/blomp-api/blob/main/CHANGELOG",
        "Documentation": "https://github.com/Izak76/blomp-api/blob/main/README.md",
        "Homepage": "https://pypi.org/project/blomp-api",
        "Source Code": "https://github.com/Izak76/blomp-api"
    },
    "split_keywords": [
        "python",
        "web api",
        "blomp",
        "rest"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5f66e913af724ead87d197925f5f2f2f994d92067ed3d8cdac0157a883d95636",
                "md5": "90eb3d81215844606404acf5af2a780c",
                "sha256": "d9940f903e3f1dfafad63d06a5dcd04e86f1d9d1d51ea3634253dcb8d869414d"
            },
            "downloads": -1,
            "filename": "blomp_api-1.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "90eb3d81215844606404acf5af2a780c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 17913,
            "upload_time": "2024-03-03T15:55:42",
            "upload_time_iso_8601": "2024-03-03T15:55:42.086829Z",
            "url": "https://files.pythonhosted.org/packages/5f/66/e913af724ead87d197925f5f2f2f994d92067ed3d8cdac0157a883d95636/blomp_api-1.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a330569c373cf2f76c4e9f4db338062883fdb7ac9f8e58219c00ae7a514c54ab",
                "md5": "90388751b7c5b54876fbe274883640dd",
                "sha256": "eb6c9a8b0a460c37e36b96cd60848dff13c0ad7621e0a4d51a3f04e34c6874de"
            },
            "downloads": -1,
            "filename": "blomp_api-1.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "90388751b7c5b54876fbe274883640dd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 16916,
            "upload_time": "2024-03-03T15:55:43",
            "upload_time_iso_8601": "2024-03-03T15:55:43.724410Z",
            "url": "https://files.pythonhosted.org/packages/a3/30/569c373cf2f76c4e9f4db338062883fdb7ac9f8e58219c00ae7a514c54ab/blomp_api-1.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-03 15:55:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Izak76",
    "github_project": "blomp-api",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "requests",
            "specs": []
        },
        {
            "name": "requests_toolbelt",
            "specs": []
        }
    ],
    "lcname": "blomp-api"
}
        
Elapsed time: 0.69561s