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.
= pd.read_csv("./uuids.csv")
df = [row["asset_uuid"] for _, row in df.iterrows()]
item_ids return item_ids
# Call the function to get the list of item ids.
= get_item_ids()
item_ids
# Load Drupal credentials from a .env file using the DrupalAPIClient.
= DrupalAPIClient.load_credentials("../.env")
DRUPAL_URL, DRUPAL_USERNAME, DRUPAL_PASSWORD
# Create an instance of the DrupalAPIClient with the loaded credentials.
= DrupalAPIClient(DRUPAL_URL, DRUPAL_USERNAME, DRUPAL_PASSWORD)
drupal
= "field_item_id"
field_name = drupal.get_nids(item_ids, field_name)
nids
= drupal.delete_from_nids(nids) results