Changeset 38704


Ignore:
Timestamp:
2024-02-06T14:04:44+13:00 (4 months ago)
Author:
davidb
Message:

filename to regex safe function added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs3-installations/intermuse/trunk/sites/intermuse/collect/ephemeral-heterogeneous/prepare/pagedimagemd.py

    r38701 r38704  
    77MetadataDirectoryRules = {
    88    'RCM BMS chapters programmes and congress'  : {},
    9     'YorkHMS BMS Borthwick IIIF/BMS'          : {
     9    'York|HMS BMS Borthwick IIIF/BMS'          : {
    1010        "type"       : "Programme",
    1111        "publisher"  : "The British Music Society of York",
    1212        "file-regex" : r'^BMS_\d+.*\.pdf$'
    1313    },
    14     'YorkHMS BMS Borthwick IIIF/HMS'          : {
     14    'York|HMS BMS Borthwick IIIF/HMS'          : {
    1515        "type": "Programme",
    1616        "publisher" : "The Huddersfield Music Society",
     
    3434    'New Zealand'                               : {},
    3535    'York BMS 1921 single programme'            : {},
    36     'BMS AnnualCat. 1920 - Bodleian copy'     : {},
     36    'BMS Annual|Cat. 1920 - Bodleian copy'     : {},
    3737    'Bradford BMS'                              : {},
    3838    'Birmingham BMS'                            : {},
    39     'BMS AnnualCat. 1922 - Lewis Foreman copy': {},
     39    'BMS Annual|Cat. 1922 - Lewis Foreman copy': {},
    4040    'Blackpool BMS'                             : {}
    4141}
     42
     43
     44def make_filename_re_safe(filename):
     45   
     46    safe1  = re.sub(r"\.","\\.",filename) # . safe
     47    safe2  = re.sub(r"\|","\\|",safe1)    # | safe
     48    safe3  = re.sub(r"\(","\\(",safe2)    # (
     49    safe4  = re.sub(r"\)","\\)",safe3)    # )
     50
     51    final_safe = "^"+safe4+"$"
     52
     53    return final_safe
    4254
    4355
     
    7789        )
    7890
    79         pdf_filename_re = "^"+re.sub(r"\.","\\.",pdf_filename)+"$"
     91        pdf_filename_re = make_filename_re_safe(pdf_filename)
    8092       
    8193        metadata_fileset = { "FileSet": { "FileName": f"{pdf_filename_re}", "Descriptions": metadata_description_list } }
Note: See TracChangeset for help on using the changeset viewer.