From 0a62bedeefc31d9d22e6f12b25728bcadfde0766 Mon Sep 17 00:00:00 2001 From: Shuichiro MAKIGAKI Date: Wed, 13 Oct 2021 00:33:59 +0900 Subject: [PATCH] Use yandeley instead of mendeley --- mendeley_cli/__init__.py | 25 +++++++++++++++++++++---- requirements.txt | 2 +- setup.py | 2 +- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/mendeley_cli/__init__.py b/mendeley_cli/__init__.py index a57013e..60fcdc4 100644 --- a/mendeley_cli/__init__.py +++ b/mendeley_cli/__init__.py @@ -9,10 +9,10 @@ from urllib import parse import json -from mendeley import Mendeley, MendeleyAuthorizationCodeAuthenticator -from mendeley.session import MendeleySession -from mendeley.auth import MendeleyAuthorizationCodeTokenRefresher -from mendeley.exception import MendeleyApiException, MendeleyException +from yandeley import Mendeley, MendeleyAuthorizationCodeAuthenticator +from yandeley.session import MendeleySession +from yandeley.auth import MendeleyAuthorizationCodeTokenRefresher +from yandeley.exception import MendeleyApiException, MendeleyException import click from tablib import formats, Dataset from dotenv import load_dotenv @@ -247,6 +247,23 @@ def cmd_get_groups(print_format): print_table(dataset, print_format) +# @cmd_get.command(name='annotations') +# @click.option('--document-uuid', type=click.UUID, help='Document UUID') +# @click.option('--print-format', type=click.Choice(tablib_formats), help='Print format') +def cmd_get_annotations(document_uuid, group_uuid, print_format): + """Get annotations""" + annotations = list(get_session().annotations.iter()) + dataset = Dataset(headers=['UUID', 'Color', 'created', 'Type', 'document', 'last_modified', 'positions', 'privacy_level', 'profile', 'text']) + for annot in annotations: + dataset.append([ + annot.id, + [annot.color.r, annot.color.g, annot.color.b], + annot.created, annot.type, annot.document().id, annot.last_modified, + [[(int(_.top_left.x), int(_.top_left.y)), (int(_.bottom_right.x), int(_.bottom_right.y), _.page)] for _ in annot.positions], + annot.privacy_level, annot.profile.id, annot.text]) + print_table(dataset, print_format) + + @cmd_create.command(name='document') @click.option('--title', type=click.STRING, required=True, help='Document title (e.g --title "Paper One")') @click.option('--doctype', type=click.STRING, default='generic', show_default=True, diff --git a/requirements.txt b/requirements.txt index 35236e7..5c90c3d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ requests -mendeley +yandeley click tablib[all] python-dotenv \ No newline at end of file diff --git a/setup.py b/setup.py index 9d599de..5998933 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='mendeley-cli', - version='0.1.4', + version='0.2.0', packages=find_packages(), include_package_data=True, install_requires=Path('requirements.txt').read_text().splitlines(),