예제 #1
0
    def get_documents_by_group_id(self, group_id: str) -> [Document]:
        """
        Get document object by profile_id
        :param profile_id:
        :param all_view:
        :return:
        """
        if not is_valid_mendeley_id(group_id):
            return None

        results = []

        # Construct a file path relative to the project root
        path = get_relative_path('test', 'samples', 'documents', 'by_group_id',
                                 '%s.json' % group_id)

        # Check if path exists
        if not exists(path):
            return []

        # If yes open and parse json
        with open(path, 'r', encoding="utf-8") as json_file:
            json_data = json.load(json_file)

            for json_doc in json_data:
                doc = get_document_from_json(json_doc)
                results.append(doc)

        return results
예제 #2
0
    def get_documents_by_group_id(self, group_id: str) -> [Document]:
        """
        Get document object by profile_id
        :param profile_id:
        :param all_view:
        :return:
        """
        if not is_valid_mendeley_id(group_id):
            return None

        results = []

        # Construct a file path relative to the project root
        path = get_relative_path('test', 'samples', 'documents', 'by_group_id', '%s.json' % group_id)

        # Check if path exists
        if not exists(path):
            return []

        # If yes open and parse json
        with open(path, 'r', encoding="utf-8") as json_file:
            json_data = json.load(json_file)

            for json_doc in json_data:
                doc = get_document_from_json(json_doc)
                results.append(doc)

        return results
예제 #3
0
    def get_documents_by_group_id(self, group_id: str) -> [Document]:
        if not self._initialized:
            log.critical("get_documents_by_group_id has been fired but the SDKCrawler was not initialized")
            return []
        results = []

        documents = self._session.group_documents(group_id).iter(view='all')
        for document in documents:
            d = get_document_from_json(document.json)
            results.append(d)
        return results
예제 #4
0
    def get_documents_by_group_id(self, group_id: str) -> [Document]:
        if not self._initialized:
            log.critical(
                "get_documents_by_group_id has been fired but the SDKCrawler was not initialized"
            )
            return []
        results = []

        documents = self._session.group_documents(group_id).iter(view='all')
        for document in documents:
            d = get_document_from_json(document.json)
            results.append(d)
        return results
예제 #5
0
    def get_documents_by_profile_id(self, profile_id: str) -> [Document]:
        if not self._initialized:
            log.critical("get_documents_by_profile_id has been fired but the SDKCrawler was not initialized")
            return []
        results = []

        """
        Unfortunately the official Mendeley SDK has no support for document queries by non-logged-in profile-ids
        Therefore i'll hack around that and reuse the session object to authenticate my own call.
        Critical SDK class:
        https://github.com/Mendeley/mendeley-python-sdk/blob/master/mendeley/resources/documents.py
        """

        documents = ExtendedDocuments(self._session).iter(view='all', profile_id=profile_id, authored='true')
        for document in documents:
            d = get_document_from_json(document.json)
            results.append(d)
        return results
예제 #6
0
    def get_documents_by_profile_id(self, profile_id: str) -> [Document]:
        if not self._initialized:
            log.critical(
                "get_documents_by_profile_id has been fired but the SDKCrawler was not initialized"
            )
            return []
        results = []
        """
        Unfortunately the official Mendeley SDK has no support for document queries by non-logged-in profile-ids
        Therefore i'll hack around that and reuse the session object to authenticate my own call.
        Critical SDK class:
        https://github.com/Mendeley/mendeley-python-sdk/blob/master/mendeley/resources/documents.py
        """

        documents = ExtendedDocuments(self._session).iter(
            view='all', profile_id=profile_id, authored='true')
        for document in documents:
            d = get_document_from_json(document.json)
            results.append(d)
        return results