Drupal Tools

Tools for working with data in an instance of Drupal.

Install

pip install git+https://github.com/nakamura196/drupal_tools

How to use

See the documentation for full details of the Omeka API Client.

Please create .env file in the root of your project with the following content:

DRUPAL_URL=http://example.org/drupal
DRUPAL_USERNAME=username
DRUPAL_PASSWORD=password
from drupal_tools.api import DrupalAPIClient

import pandas as pd

def get_item_ids():
    # Load a CSV file containing item ids into a DataFrame.
    df = pd.read_csv("./uuids.csv")
    item_ids = [row["asset_uuid"] for _, row in df.iterrows()]
    return item_ids

# Call the function to get the list of item ids.
item_ids = get_item_ids()

# Load Drupal credentials from a .env file using the DrupalAPIClient.
DRUPAL_URL, DRUPAL_USERNAME, DRUPAL_PASSWORD = DrupalAPIClient.load_credentials("../.env")

# Create an instance of the DrupalAPIClient with the loaded credentials.
drupal = DrupalAPIClient(DRUPAL_URL, DRUPAL_USERNAME, DRUPAL_PASSWORD)

field_name = "field_item_id"
nids = drupal.get_nids(item_ids, field_name)

results = drupal.delete_from_nids(nids)