diff --git a/README.md b/README.md index 26e8aa0..546ecd4 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ Library and cli to manage and interact with your Google Drive, sheets and docs 0. [Introduction](#introduction) 0. [Obtaining credentials for Google APIs](#wrench-obtaining-credentials-for-google-apis) +0. [Installing google-drive CLI](#installing-google-drive-cli) +0. [CLI Documentation](#cli-documentation) 0. [Contributing](#family-contributing) 0. [License](#page_with_curl-license) @@ -62,6 +64,121 @@ To generate this we have the make target google-auth, so, you just have to tun :angel: So, you don't have to worry about that :smiley: + +# Installing google-drive CLI + +## Using make + +``` +make install +``` + +## Using pip + +``` +pip install google-drive +``` + +### With specific version + +Look for available versions with: + +``` +pip install google-drive== +``` + +And select one and run: + +``` +pip install google-drive== +``` + +# CLI Documentation + +## google-drive --help + +Shows the help message + +### Usage + +``` +> google-drive --help +Usage: google-drive [OPTIONS] COMMAND [ARGS]... + +Options: + --help Show this message and exit. + +Commands: + get Get file metadata + login Perform a login with google oauth + ls List directory contents + mkdir Make directory +``` + +## google-drive login + +Perform a login with google oauth. + +### Usage + +``` +> google-drive login +``` + +## google-drive ls + +List directory contents + +### Usage + +``` +> google-drive ls / +- (, , ) +- (, , ) +- (, , ) +... +- (, , ) +``` + +## google-drive get + +Get file metadata + +### Usage + +``` +> google-drive get + +File Metadata: +== +id: +name: +parents: [''] +mime_type: +export_links: + - application/rtf: https://docs.google.com/feeds/download/documents/export/Export?id=&exportFormat=rtf + - application/vnd.oasis.opendocument.text: https://docs.google.com/feeds/download/documents/export/Export?id=&exportFormat=odt + - text/html: https://docs.google.com/feeds/download/documents/export/Export?id=&exportFormat=html + - application/pdf: https://docs.google.com/feeds/download/documents/export/Export?id=&exportFormat=pdf + - application/epub+zip: https://docs.google.com/feeds/download/documents/export/Export?id=&exportFormat=epub + - application/zip: https://docs.google.com/feeds/download/documents/export/Export?id=&exportFormat=zip + - application/vnd.openxmlformats-officedocument.wordprocessingml.document: https://docs.google.com/feeds/download/documents/export/Export?id=&exportFormat=docx + - text/plain: https://docs.google.com/feeds/download/documents/export/Export?id=&exportFormat=txt + ``` + +## google-drive mkdir + +Make directory + +### Usage + +``` +> google-drive mkdir +(, , application/vnd.google-apps.folder) +``` + +# Using googledrive as API SDK + ## :family: Contributing [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md) diff --git a/TODO.md b/TODO.md index 0519e4a..aafd2f9 100644 --- a/TODO.md +++ b/TODO.md @@ -2,21 +2,24 @@ ## Project management -- [ ] Add documentation +- [X] Add CLI documentation +- [ ] Add API documentation - [ ] Add examples of usage the api.py from a piece of code. - [ ] Add pull requests and issues templates - [X] Add CONTRIBUTING ## Functionalities -- [X] Implement `get` to get file metadata -- [ ] Extending `ls` for an ID file. -- [ ] Extending `mkdir` for a path folder. -- [ ] Implement `analysis` to extract data from the google drive. -- [ ] Implement `cat` for a google doc file. -- [ ] Implement `touch` for create an empty google doc, spreadsheet, presentation, form, ... -- [ ] Implement `cp` for a google doc file. From source path to destiny path. -- [ ] Implement `mv` for a google doc file. From source path to destiny path. -- [ ] Implement open_file help function for spreadsheets files. This will retrieve an object that will allow us manage that file; reading (readlines); updating; removing, ... -- [ ] Implement readlines help function for spreadsheets files reading. -- [ ] Nice print for cli output. +- [X][CLI] Implement `get` to get file metadata +- [ ][CLI] Extending `ls` for an ID file. +- [ ][CLI] Extending `mkdir` for a path folder. +- [ ][CLI] Implement `rmdir` for a path folder. +- [ ][CLI] Implement `analysis` to extract data from the google drive. +- [ ][CLI] Implement `cat` for a google doc file. +- [ ][CLI] Implement `touch` for create an empty google doc, spreadsheet, presentation, form, ... +- [ ][CLI] Implement `cp` for a google doc file. From source path to destiny path. +- [ ][CLI] Implement `mv` for a google doc file. From source path to destiny path. +- [ ][API] Implement open_file help function for spreadsheets files. This will retrieve an object that will allow us manage that file; reading (readlines); updating; removing, ... +- [ ][API] Implement readlines help function for spreadsheets files reading. +- [ ][CLI] Nice print for cli output. +- [ ][CLI] Add logger with different levels of logging: {ERROR, WARNING, INFO, DEBUG} diff --git a/googledrive/api.py b/googledrive/api.py index 094586a..2f8d2eb 100644 --- a/googledrive/api.py +++ b/googledrive/api.py @@ -85,6 +85,7 @@ class GoogleDrive(GoogleService): MIMETYPE_FOLDER = 'application/vnd.google-apps.folder' MIMETYPE_DOCUMENT = 'application/vnd.google-apps.document' MIMETYPE_SPREADSHEET = 'application/vnd.google-apps.spreadsheet' + MIMETYPE_PDF = 'application/pdf' FIELDS_BASIC_FILE_METADATA = 'id, name, parents, mimeType' FIELDS_FILE_METADATA = f'{FIELDS_BASIC_FILE_METADATA}, exportLinks' @@ -92,7 +93,8 @@ class GoogleDrive(GoogleService): QUERY_IS_FOLDER = f"mimeType='{MIMETYPE_FOLDER}'" QUERY_IS_DOCUMENT = f"mimeType='{MIMETYPE_DOCUMENT}'" QUERY_IS_SPREADSHEET = f"mimeType='{MIMETYPE_SPREADSHEET}'" - QUERY_IS_FILE = f"({QUERY_IS_SPREADSHEET} or {QUERY_IS_DOCUMENT})" + QUERY_IS_PDF = f"mimeType='{MIMETYPE_PDF}'" + QUERY_IS_FILE = f"({QUERY_IS_FOLDER} or {QUERY_IS_SPREADSHEET} or {QUERY_IS_DOCUMENT} or {QUERY_IS_PDF})" # # Simple structures for cached responses diff --git a/requirements/dev.txt b/requirements/dev.txt index a6f9b59..75f5ae0 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,14 +1,14 @@ # linter -pylint==2.4.4 +pylint==2.16.0b1 # format python code to PEP 8 stlye guide -autopep8==1.5 +autopep8==2.0.1 # test runner -pytest==5.4.1 -pytest-cov==2.8.1 +pytest==7.2.1 +pytest-cov==4.0.0 # upgraded Python shell for dev env -ipython==7.13.0 +ipython==7.23.1 -codecov==2.1.3 +codecov==2.1.12 diff --git a/requirements/prod.txt b/requirements/prod.txt index 2a1a01e..2f8403f 100644 --- a/requirements/prod.txt +++ b/requirements/prod.txt @@ -1,5 +1,5 @@ -google-api-python-client==1.8.0 -google-auth-httplib2==0.0.3 +google-api-python-client==2.6.0 +google-auth-httplib2==0.1.0 google-auth-oauthlib==0.4.1 dataclasses==0.6