Changeset 37727


Ignore:
Timestamp:
2023-04-25T17:24:32+12:00 (12 months ago)
Author:
davidb
Message:

Updated to work with newly structured spreadsheet that separates out Online (File) and DriveLink

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs3-installations/thewillow/trunk/sites/thewillow/collect/community-contributions/prepare/xlsx-to-csv--thewillow-directorysheet.py

    r37649 r37727  
    3333    "Description"       : { "gsheading": "Description"    },
    3434    "Creation Date"     : { "gsheading": "CreationDate"   },
    35     "Orginial/ Copy"    : { "gsheading": "OirginalOrCopy" },
     35    "Orginial/ Copy"    : { "gsheading": "OriginalOrCopy" },
    3636    "File"              : { "gsheading": "FileNote"       },
     37    "DriveLink"         : { "gsheading": "DriveNote"       },
    3738    "Library Reference" : { "gsheading": "LibraryRefNum"  },
    3839    "Copyright?"        : { "gsheading": "InCopyright"    },
     
    4950#
    5051ExtraHeadings = {
    51     "Filename"     : { "colpos": 1 },
    52     "DLIdentifier" : { "colpos": 2 },
    53     "OrigFilename" : { "colpos": 3 },
    54     "OptHyperlink" : None
     52    "Filename"          : { "colpos": 1 },
     53    "FilenameAssocwith" : { "colpos": 2 },
     54    "DLIdentifier"      : { "colpos": 3 },
     55    "OrigFilename"      : { "colpos": 4 },
     56    "OrigDrivename"     : { "colpos": 5 },
     57    "OptHyperlink"      : None,
     58    "OptDrivelink"      : None
    5559}
    5660   
     
    259263       
    260264        # print("    row: " + str(row_i))
    261 
     265        sys.stdout.write("["+ str(row_i) + "] " )
     266        sys.stdout.flush()
     267       
    262268        dl_identifier_str = "tw-contrib-%04d" % dl_identifier
    263269       
     
    298304            worksheet.cell(row=row_i, column=filename_colpos, value=renamed_filename)
    299305
    300            
     306        drivenote_colpos = HeadingsTransformation["DriveLink"]["colpos"]
     307
     308        drivenote_cell = worksheet.cell(row=row_i, column=drivenote_colpos)
     309        opt_drivelink  = drivenote_cell.hyperlink
     310           
     311        if opt_drivelink != None:
     312           
     313            opt_drivelink_colpos = HeadingsTransformation["OptDrivelink"]["colpos"]
     314            doc_url = opt_drivelink.target
     315            worksheet.cell(row=row_i, column=opt_drivelink_colpos, value=doc_url)
     316           
     317            downloaded_filename = downloadGoogleDoc(doc_url)
     318
     319            orig_file = os.path.basename(downloaded_filename)
     320
     321            # Determine if this will be the primary (doc) file, or an assoicated file
     322            orig_filename_colpos = HeadingsTransformation["OrigFilename"]["colpos"]
     323            orig_filename_value = worksheet.cell(row=row_i, column=orig_filename_colpos).value
     324
     325            downloaded_filename = optConvertDocToPdf(downloaded_filename)
     326           
     327            if orig_filename_value is None or orig_filename_value == "":
     328                # Make this the primary file/doc
     329                worksheet.cell(row=row_i, column=orig_filename_colpos, value=orig_file)
     330
     331                renamed_filename = fileRenameToDLIdentifier(downloaded_filename,dl_identifier_str)
     332
     333                filename_colpos = HeadingsTransformation["Filename"]["colpos"]
     334                worksheet.cell(row=row_i, column=filename_colpos, value=renamed_filename)               
     335            else:
     336                orig_drivename_colpos = HeadingsTransformation["OrigDrivename"]["colpos"]
     337               
     338                worksheet.cell(row=row_i, column=orig_drivename_colpos, value=orig_file)
     339
     340                dl_identifier_assocwith_str = "tw-contrib-%04d-assocwith" % dl_identifier
     341               
     342                renamed_filename = fileRenameToDLIdentifier(downloaded_filename,dl_identifier_assocwith_str)
     343
     344                # We store this in the spreasheet mostly for auditing purposes
     345                # The actual 'assocwith' DL behaviour is triggered by the plugin option,
     346                # driven by a regular expression matching on the two filenames
     347                filename_assocwith_colpos = HeadingsTransformation["FilenameAssocwith"]["colpos"]
     348                worksheet.cell(row=row_i, column=filename_assocwith_colpos, value=renamed_filename)               
     349
    301350        dl_identifier += 1
    302351        row_i += 1
Note: See TracChangeset for help on using the changeset viewer.