def copyWiki(syn, entity, destinationId, entitySubPageId=None, destinationSubPageId=None, updateLinks=True, updateSynIds=True, entityMap=None):
    """
    Copies wikis and updates internal links

    :param entity:                  A synapse ID of an entity whose wiki you want to copy

    :param destinationId:           Synapse ID of a folder/project that the wiki wants to be copied to
    
    :param updateLinks:             Update all the internal links
                                    Defaults to True

    :param updateSynIds:            Update all the synapse ID's referenced in the wikis
                                    Defaults to True but needs an entityMap

    :param entityMap:               An entity map {'oldSynId','newSynId'} to update the synapse IDs referenced in the wiki
                                    Defaults to None 

    :param entitySubPageId:         Can specify subPageId and copy all of its subwikis
                                    Defaults to None, which copies the entire wiki
                                    subPageId can be found: https://www.synapse.org/#!Synapse:syn123/wiki/1234
                                    In this case, 1234 is the subPageId. 

    :param destinationSubPageId:    Can specify destination subPageId to copy wikis to
                                    Defaults to None
    """
    oldOwn = syn.get(entity,downloadFile=False)
    # getWikiHeaders fails when there is no wiki
    try:
        oldWh = syn.getWikiHeaders(oldOwn)
        store = True
    except SynapseHTTPError:
        store = False
    if store:
        if entitySubPageId is not None:
            oldWh = _getSubWikiHeaders(oldWh,entitySubPageId,mapping=[])
        newOwn =syn.get(destinationId,downloadFile=False)
        wikiIdMap =dict()
        newWikis=dict()
        for i in oldWh:
            attDir=tempfile.NamedTemporaryFile(prefix='attdir',suffix='')
            #print i['id']
            wiki = syn.getWiki(oldOwn, i.id)
            print('Got wiki %s' % i.id)
            if wiki['attachmentFileHandleIds'] == []:
                attachments = []
            elif wiki['attachmentFileHandleIds'] != []:
                uri = "/entity/%s/wiki/%s/attachmenthandles" % (wiki.ownerId, wiki.id)
                results = syn.restGET(uri)
                file_handles = {fh['id']:fh for fh in results['list']}
                ## need to download an re-upload wiki attachments, ug!
                attachments = []
                tempdir = tempfile.gettempdir()
                for fhid in wiki.attachmentFileHandleIds:
                    file_info = syn._downloadWikiAttachment(wiki.ownerId, wiki, file_handles[fhid]['fileName'], destination=tempdir)
                    attachments.append(file_info['path'])
            #for some reason some wikis don't have titles?
            if hasattr(i, 'parentId'):
                wNew = Wiki(owner=newOwn, title=wiki.get('title',''), markdown=wiki.markdown, attachments=attachments, parentWikiId=wikiIdMap[wiki.parentWikiId])
                wNew = syn.store(wNew)
            else:
                wNew = Wiki(owner=newOwn, title=wiki.get('title',''), markdown=wiki.markdown, attachments=attachments, parentWikiId=destinationSubPageId)
                wNew = syn.store(wNew)
                parentWikiId = wNew.id
            newWikis[wNew.id]=wNew
            wikiIdMap[wiki.id] =wNew.id

        if updateLinks:
            print("Updating internal links:\n")
            for oldWikiId in wikiIdMap.keys():
                # go through each wiki page once more:
                newWikiId=wikiIdMap[oldWikiId]
                newWiki=newWikis[newWikiId]
                print(newWikiId % "\tUpdating internal links for Page: %s\n")
                s=newWiki.markdown
                # in the markdown field, replace all occurrences of entity/wiki/abc with destinationId/wiki/xyz,
                # where wikiIdMap maps abc->xyz
                # replace <entity>/wiki/<oldWikiId> with <destinationId>/wiki/<newWikiId> 
                for oldWikiId2 in wikiIdMap.keys():
                    oldProjectAndWikiId = "%s/wiki/%s" % (entity, oldWikiId2)
                    newProjectAndWikiId = "%s/wiki/%s" % (destinationId, wikiIdMap[oldWikiId2])
                    s=re.sub(oldProjectAndWikiId, newProjectAndWikiId, s)
                # now replace any last references to entity with destinationId
                s=re.sub(entity, destinationId, s)
                newWikis[newWikiId].markdown=s

        if updateSynIds and entityMap is not None:
            print("Updating Synapse references:\n")
            for oldWikiId in wikiIdMap.keys():
                # go through each wiki page once more:
                newWikiId = wikiIdMap[oldWikiId]
                newWiki = newWikis[newWikiId]
                print('Updated Synapse references for Page: %s\n' %newWikiId)
                s = newWiki.markdown

                for oldSynId in entityMap.keys():
                    # go through each wiki page once more:
                    newSynId = entityMap[oldSynId]
                    s = re.sub(oldSynId, newSynId, s)
                print("Done updating Synpase IDs.\n")
                newWikis[newWikiId].markdown = s
        
        print("Storing new Wikis\n")
        for oldWikiId in wikiIdMap.keys():
            newWikiId = wikiIdMap[oldWikiId]
            newWikis[newWikiId] = syn.store(newWikis[newWikiId])
            print("\tStored: %s\n",newWikiId)
        newWh = syn.getWikiHeaders(newOwn)
        return(newWh)
    else:
        return("no wiki")
dataset/ETHPy150Open Sage-Bionetworks/synapsePythonClient/synapseutils/copy.py/copyWiki/swapped operands of `%`