Skip to content

Commit

Permalink
Add pid script
Browse files Browse the repository at this point in the history
  • Loading branch information
tmorrell committed Aug 29, 2024
1 parent 3990a43 commit ccc38c4
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions scripts/get_pid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import click, os

from flask.cli import with_appcontext
from invenio_db import db
from invenio_files_rest.models import ObjectVersion
from invenio_utilities_tuw.utils import get_identity_for_user, get_record_service
from invenio_pidstore.models import PersistentIdentifier

@click.command('delete_pid')
@click.argument('pid', type=str)
@with_appcontext
def get_pid(pid):
"""Get pid"""
service = get_record_service()
provider = service.pids.pid_manager._get_provider("doi", "external")
pid_uuid = provider.get(pid_value=pid).object_uuid
query = PersistentIdentifier.query.filter_by(
object_uuid=pid_uuid,
pid_type="recid",
)
pid_value = query.first().pid_value

print(pid_value)


if __name__=="__main__":
get_pid()

0 comments on commit ccc38c4

Please sign in to comment.