#!/usr/bin/env python3 """ Consolidate Le Passé Ltd / La Passe, Ltd duplicates into one file. These are the SAME art dealership with variant spelling on Wikidata: - Q135997285: Le Passé Ltd - Q136003694: La Passe, Ltd (has more properties - Getty Museum IDs) Historical context: - Founded by Nicolas de Koenigsberg in New York (East 57th Street) as "Le Passe, Ltd" - Expanded to South America in 1941 - After Nicolas died in 1952, Paula de Koenigsberg continued in Buenos Aires - Had branches in Paris, New York, Mexico City, and Buenos Aires Decision: Consolidate to ONE Argentina file with Buenos Aires location. The richer Wikidata entry (Q136003694) will be primary, Q135997285 noted as duplicate. """ import os import sys from datetime import datetime, timezone import yaml # Custom YAML representer to handle multiline strings nicely def str_representer(dumper, data): if '\n' in data: return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|') return dumper.represent_scalar('tag:yaml.org,2002:str', data) yaml.add_representer(str, str_representer) def main(): dry_run = '--dry-run' in sys.argv custodian_dir = '/Users/kempersc/apps/glam/data/custodian' # Files to consolidate file_lpl = os.path.join(custodian_dir, 'AR-XX-XXX-G-LPL.yaml') # Q135997285 file_pl = os.path.join(custodian_dir, 'AR-XX-XXX-G-PL.yaml') # Q136003694 # New consolidated file - Buenos Aires location new_file = os.path.join(custodian_dir, 'AR-C-BUE-G-LPL.yaml') print("=" * 60) print("Le Passé Ltd / La Passe, Ltd Duplicate Consolidation") print("=" * 60) print(f"\nDry run: {dry_run}") # Check files exist if not os.path.exists(file_lpl): print(f"ERROR: {file_lpl} not found") return if not os.path.exists(file_pl): print(f"ERROR: {file_pl} not found") return # Load both files with open(file_lpl, 'r', encoding='utf-8') as f: data_lpl = yaml.safe_load(f) with open(file_pl, 'r', encoding='utf-8') as f: data_pl = yaml.safe_load(f) print(f"\nSource file 1: {os.path.basename(file_lpl)}") print(f" Wikidata: Q135997285 (Le Passé Ltd)") print(f"\nSource file 2: {os.path.basename(file_pl)}") print(f" Wikidata: Q136003694 (La Passe, Ltd) - RICHER DATA") # Create consolidated entry # Use "Le Passé Ltd" as primary name (more common spelling based on sources) # But reference Q136003694 as primary Wikidata (has Getty Museum IDs) now = datetime.now(timezone.utc).isoformat() consolidated = { 'original_entry': { 'name': 'Le Passé Ltd', 'source': 'Wikidata SPARQL import (consolidated)', 'wikidata_id': 'Q136003694', # Richer entry 'alternate_wikidata_ids': ['Q135997285'], # Duplicate to merge 'consolidation_notes': 'Two Wikidata entries (Q135997285, Q136003694) represent the same art dealership with variant spelling. Consolidated 2025-12-19.' }, 'processing_timestamp': now, 'ghcid': { 'ghcid_current': 'AR-C-BUE-G-LPL', 'ghcid_uuid': data_lpl['ghcid']['ghcid_uuid'], # Keep original UUID for stability 'ghcid_uuid_sha256': data_lpl['ghcid']['ghcid_uuid_sha256'], 'ghcid_numeric': data_lpl['ghcid']['ghcid_numeric'], 'record_id': data_lpl['ghcid']['record_id'], 'generation_timestamp': now, 'location_resolution': { 'method': 'HISTORICAL_RESEARCH', 'country_code': 'AR', 'region_code': 'C', # CABA 'region_name': 'Ciudad Autónoma de Buenos Aires', 'city_code': 'BUE', 'city_name': 'Buenos Aires', 'research_date': now, 'research_sources': [ { 'type': 'web_article', 'url': 'https://www.nytimes.com/1952/08/02/archives/n-de-koenigsberg-sr.html', 'title': 'N. DE KOENIGSBERG SR. - The New York Times (1952)', 'excerpt': 'He had a gallery on East Fifty-seventh Street here, known as Le Passe, Ltd., before he extended his interests to South America in 1941.' }, { 'type': 'provenance_database', 'url': 'https://inventario.nostraetmundi.com/en/location/228', 'title': 'Paula de Koenigsberg - Nostra et Mundi', 'excerpt': 'She established branches around the world... among the most significant locations were Paris, New York, Mexico City, and Buenos Aires.' }, { 'type': 'auction_record', 'url': 'https://www.sothebys.com/buy/c1b9b732-ab5d-481e-bfad-a5bb069a44f7/lots/b667cc01-6352-4fb3-a7bb-98d14c22ad9e', 'title': "Sotheby's provenance record", 'excerpt': 'with Nicolas de Koenigsberg (1882-1952), Le Passé Ltd, Buenos Aires; thence by descent to his wife, Paula de Koenigsberg, Buenos Aires' } ], 'notes': 'Gallery founded in New York by Nicolas de Koenigsberg, expanded to Buenos Aires in 1941. After his death in 1952, Paula de Koenigsberg continued operations primarily from Buenos Aires.' }, 'ghcid_history': [ { 'ghcid': 'AR-C-BUE-G-LPL', 'valid_from': now, 'valid_to': None, 'reason': 'Consolidated from duplicate AR-XX-XXX entries. Location resolved to Buenos Aires based on historical research.' }, { 'ghcid': 'AR-XX-XXX-G-LPL', 'valid_from': data_lpl['ghcid']['generation_timestamp'], 'valid_to': now, 'reason': 'Initial import from Wikidata Q135997285 without resolved location' }, { 'ghcid': 'AR-XX-XXX-G-PL', 'valid_from': data_pl['ghcid']['generation_timestamp'], 'valid_to': now, 'reason': 'Duplicate entry from Wikidata Q136003694, now consolidated' } ] }, 'custodian_name': { 'claim_type': 'custodian_name', 'claim_value': 'Le Passé Ltd', 'source_type': 'wikidata', 'emic_name': 'Le Passé Ltd', 'name_language': 'fr', # French name 'alternate_names': [ 'La Passe, Ltd', 'Le Passe, Ltd' ] }, 'institution_type': 'GALLERY', 'description': """Le Passé Ltd was an art dealership founded by Nicolas de Koenigsberg (1882-1952) on East 57th Street in New York City. In 1941, he expanded operations to South America, establishing a significant presence in Buenos Aires. After Nicolas's death in 1952, his widow Paula de Koenigsberg continued the business, establishing branches in Paris, New York, Mexico City, and Buenos Aires. The gallery is notable for handling significant artworks, including pieces now in the J. Paul Getty Museum collection. The name appears in variant spellings (Le Passé, La Passe) across different records.""", 'location': { 'country': 'AR', 'region_code': 'C', 'city': 'Buenos Aires', 'notes': 'Primary Argentina location. Gallery also operated in New York (original), Mexico City, and Paris.' }, 'multinational_presence': { 'is_multinational': True, 'countries_of_operation': [ { 'country_code': 'US', 'city': 'New York', 'role': 'founding_location', 'period': '1920s-1952+' }, { 'country_code': 'AR', 'city': 'Buenos Aires', 'role': 'expansion', 'period': '1941-1970s+' }, { 'country_code': 'MX', 'city': 'Mexico City', 'role': 'branch', 'period': 'mid-20th century' }, { 'country_code': 'FR', 'city': 'Paris', 'role': 'branch', 'period': 'mid-20th century' } ], 'notes': 'This file represents the Argentina presence. US/MX/FR files could be created separately if needed.' }, 'founding_info': { 'founder': 'Nicolas de Koenigsberg', 'founder_wikidata': 'Q135997213', 'founding_location': 'New York City, USA', 'argentina_expansion_year': 1941, 'succession': 'Paula de Koenigsberg (widow) after 1952', 'successor_wikidata': 'Q135891878' }, 'wikidata_enrichment': { 'wikidata_entity_id': 'Q136003694', 'duplicate_wikidata_ids': ['Q135997285'], 'duplicate_status': 'RECOMMEND_MERGE', 'duplicate_notes': 'Q136003694 has more properties (Getty Museum IDs). Both entries have same owners (Paula and Nicolas de Koenigsberg). Variant spellings: Le Passé vs La Passe.', 'enrichment_date': now, 'source': 'Wikidata SPARQL import (consolidated)', 'properties': { 'instance_of': 'Q1007870 (art gallery)', 'owned_by': ['Q135891878 (Paula de Koenigsberg)', 'Q135997213 (Nicolas de Koenigsberg)'], 'country': ['Q30 (United States)', 'Q414 (Argentina)'], 'owner_of': 'Q3230385 (The Farewell of Telemachus and Eucharis)', 'getty_museum_agent_id': 'group/104ZNB', 'getty_museum_agent_dor_id_old': '12916', 'has_works_in_collection': 'Q731126 (J. Paul Getty Museum)' } }, 'provenance': { 'data_source': 'WIKIDATA_CONSOLIDATED', 'data_tier': 'TIER_3_CROWD_SOURCED', 'extraction_date': now, 'extraction_method': 'Manual consolidation of duplicate Wikidata entries with historical research', 'confidence_score': 0.90, 'notes': 'High confidence based on consistent ownership (Koenigsberg family) across both Wikidata entries and corroborating auction/provenance records.' } } print(f"\n{'='*60}") print("CONSOLIDATED ENTRY") print(f"{'='*60}") print(f"\nNew file: {os.path.basename(new_file)}") print(f"GHCID: AR-C-BUE-G-LPL") print(f"Name: Le Passé Ltd") print(f"Primary Wikidata: Q136003694") print(f"Duplicate Wikidata: Q135997285 (recommend merge)") print(f"Location: Buenos Aires, Argentina") print(f"Multinational: Yes (US, AR, MX, FR)") if dry_run: print(f"\n[DRY RUN] Would write: {new_file}") print(f"[DRY RUN] Would delete: {file_lpl}") print(f"[DRY RUN] Would delete: {file_pl}") print("\nRun without --dry-run to apply changes.") else: # Write consolidated file with open(new_file, 'w', encoding='utf-8') as f: yaml.dump(consolidated, f, default_flow_style=False, allow_unicode=True, sort_keys=False, width=120) print(f"\n✓ Created: {new_file}") # Delete old files os.remove(file_lpl) print(f"✓ Deleted: {file_lpl}") os.remove(file_pl) print(f"✓ Deleted: {file_pl}") print(f"\n{'='*60}") print("CONSOLIDATION COMPLETE") print(f"{'='*60}") print(f"\nResult: 2 AR-XX-XXX files → 1 AR-C-BUE-G-LPL file") print(f"\nNext steps:") print(f" 1. Consider proposing Wikidata merge: Q135997285 → Q136003694") print(f" 2. Optionally create US-NY-NYC-G-LPL.yaml for New York presence") print(f" 3. Optionally create MX-XX-XXX-G-LPL.yaml for Mexico presence") if __name__ == '__main__': main()