Metadata-Version: 2.1
Name: EGDrive
Version: 0.1.3
Summary: A Simplified Google Drive API.
Home-page: https://github.com/th3c00lw0lf/EGDrive
Author: th3c00lw0lf
Author-email: business.mam@outlook.com
License: LICENSE.txt
Classifier: Programming Language :: Python :: 3
Classifier: Development Status :: 4 - Beta
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Topic :: Communications :: File Sharing
Classifier: Topic :: Internet
Classifier: Topic :: Software Development :: Libraries
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: cachetools (==5.2.0)
Requires-Dist: certifi (==2022.9.24)
Requires-Dist: cffi (==1.15.1)
Requires-Dist: charset-normalizer (==2.1.1)
Requires-Dist: commonmark (==0.9.1)
Requires-Dist: cryptography (==38.0.1)
Requires-Dist: google-api-core (==2.10.2)
Requires-Dist: google-api-python-client (==2.64.0)
Requires-Dist: google-auth (==2.12.0)
Requires-Dist: google-auth-httplib2 (==0.1.0)
Requires-Dist: googleapis-common-protos (==1.56.4)
Requires-Dist: httplib2 (==0.20.4)
Requires-Dist: idna (==3.4)
Requires-Dist: oauth2client (==4.1.3)
Requires-Dist: protobuf (==4.21.7)
Requires-Dist: pyasn1 (==0.4.8)
Requires-Dist: pyasn1-modules (==0.2.8)
Requires-Dist: pycparser (==2.21)
Requires-Dist: PyDrive2 (==1.14.0)
Requires-Dist: Pygments (==2.13.0)
Requires-Dist: pyOpenSSL (==22.1.0)
Requires-Dist: pyparsing (==3.0.9)
Requires-Dist: PyYAML (==6.0)
Requires-Dist: requests (==2.28.1)
Requires-Dist: rich (==12.6.0)
Requires-Dist: rsa (==4.9)
Requires-Dist: six (==1.16.0)
Requires-Dist: uritemplate (==4.1.1)
Requires-Dist: urllib3 (==1.26.12)

# 📦️ EGDrive

[![Issues](https://img.shields.io/github/issues/th3c00lw0lf/EGDrive)](https://github.com/th3c00lw0lf/EGDrive/issues)  [![pypi](https://img.shields.io/pypi/v/EGDrive)](https://pypi.org/project/EGDrive/)

A simplified Google Drive API wrapper for Python.

EGDrive is a built on top of [PyDrive2](https://github.com/iterative/PyDrive2), it simplifies management of Google Drive using Python, it has a high level interface emulating Linux file management commands in an intuitive way.
## 🧑‍💻 Installation

Install EGDrive with pip

```bash
pip install EGDrive
```
    
## 📌 Features

- Intuitive Unix-like commands (ls, mkdir, rm ...) to manage Google Drive
- Access any file with it's absolute path, no more Google Drive ID's headaches.
- Built on top of [PyDrive2](https://github.com/iterative/PyDrive2), access [GoogleDrive](https://docs.iterative.ai/PyDrive2/pydrive2/#pydrive2.drive.GoogleDrive) and [GoogleAuth](https://docs.iterative.ai/PyDrive2/pydrive2/#pydrive2.drive.GoogleDrive) instances for more options.
- Lightweight.


## 🚀 Usage/Examples

### Authentication with Google Drive

Create a new project in Google's APIs Console, for that follow this guide in [here](https://docs.iterative.ai/PyDrive2/quickstart/#authentication).
To make the authentication automatic follow [this guide](https://docs.iterative.ai/PyDrive2/oauth/#automatic-and-custom-authentication-with-settings-yaml).

##### Initiate an EGDrive instance.
```python
from EGDrive import EGDrive

gdrive = EGDrive()
```

##### List files
The files that will be listed are the ones that your *Google Project has access to*, other files *won't* be managed by EGDrive.

```python
files = [file['title'] for file in gdrive.ls('root')]
for file in files:
    print(file)
```

##### Create a directory
If you try to create a directory that *already exists*, this function *won't create a new directory* with the same name and different id, instead it'll return the [`GoogleDriveFile`](https://docs.iterative.ai/PyDrive2/pydrive2/#pydrive2.files.GoogleDriveFile) instance for *the existing directory* in the drive, and if there are more than one, it'll return [`GoogleDriveFile`](https://docs.iterative.ai/PyDrive2/pydrive2/#pydrive2.files.GoogleDriveFile) for the first one that matches the name of the new directory.

```python
gdrive.mkdir("/Books")
```

##### Create even more directories
You can create as many directories as you want using mkdir , this works the same as the command `mkdir -p` in Linux.
*Please note that you should always use absolute paths!*
```python
gdrive.mkdir("/Books/Science") # equivalent to `mkdir -p Books/Science`
gdrive.mkdir("/Books/Litterature")
gdrive.mkdir("/Books/Science/Programming/JAVA")
gdrive.mkdir("/Books/Science/Programming/Python/3/")
```

##### Create an empty file
Creates a new file and returns it's [`GoogleDriveFile`](https://docs.iterative.ai/PyDrive2/pydrive2/#pydrive2.files.GoogleDriveFile) instance. if the file already exists it'll return the [`GoogleDriveFile`](https://docs.iterative.ai/PyDrive2/pydrive2/#pydrive2.files.GoogleDriveFile) instance of the existing file.
```python
gdrive.touch("/Documents/empty.txt")
```

##### Check if a file exists
```python
if gdrive.exists("/path/to/file"): print("File exists!")
else: print("File not found!")
```

##### Remove files and directories
Removing files by default moves them to Trash where they'll be permanently deleted after 30 days.

```python
# move to Trash
gdrive.rm("/Books/Science/Programming/JAVA")
# delete permanently
gdrive.rm("/Books/Litterature", permanently=True)
```

##### Download a file
```python
gdrive.download("/Books/Science/physics.pdf", "/home/user/Downloads/physics.pdf")
```
##### Upload a file
```python
gdrive.upload("/home/user/Videos/mrbean.mp4", "/Videos/mrbean.mp4")
```

##### Copy a file to a directory
```python
gdrive.cp("Books/Science/Programming/gravity.pdf", "/Books/Science/")
```
##### Copy a file to a directory and rename it
```python
gdrive.cp("/Books/Science/Programming/gravity.pdf", "/Books/Science/physics.pdf")
```

##### Get the `id` of a file or folder from it's path
```python
gdrive.path_to_id("/Books/Science/Programming/gravity.pdf")
```
##### Get the path of a file or folder by it's `id`
```python
gdrive.id_to_path("XX-XXXXXXXXXXX-XXXXXXX")
```



##### Get access to PyDrive2 [`GoogleDrive`](https://docs.iterative.ai/PyDrive2/pydrive2/#pydrive2.drive.GoogleDrive) and [`GoogleAuth`](https://docs.iterative.ai/PyDrive2/pydrive2/#pydrive2.Auth.GoogleAuth) instances
```python
gdrive.drive # GoogleDrive instance
gdrive.gauth # GoogleAuth instance
```
## 📝 TODO

- Add progress info for uploading/downloading files.
- Add support for file operations: ~~copy~~, move.
- Implement support for relative paths.
- ...

## 🩹 Known Issues

You tell me 👽️.


## 🔧 Contributing

Contributions are always welcome!
