quick search:
 

handling dreamweaver development files

Submitted by: runyaga
Last Edited: 2001-09-19

Category: Python(Script)

Average rating is: 2.0 out of 5 (1 ratings)

Description:
if you use Dreamweaver w/ ZOPE, you will notice it leaves .lck files all over the place. Also you will notice that you need file extensions. ZOPE and file extensions have a akward relationship. and i needed to be able to copy all these .html/.htm extension files to another id without the extension. this gives you quite an idea of having to move files around: cut, copy, paste and delete of objects are done.

Source (Text):
from string import lower, find
#rm .lck files

objs = context.objectIds()   #all the object ids in current folder
for id in objs:
    #trash anything that ends with .LCK
    if lower(id[-4:])=='.lck':
        print 'deleteing DW lock, ' + id
        context.manage_delObjects(id)

    #anything that ends with .htm or html
    if lower(id[-4:]) in ('.htm', 'html'):
        no_extension = id[:find(id, '.htm')]

        if no_extension in objs:
            print 'deleteing file w/o extension, ' + no_extension
            context.manage_delObjects(no_extension)

        print 'made copy of, ' + id
        context.manage_pasteObjects(context.manage_copyObjects(id))

        print 'renaming '+id+' to '+no_extension
        context.manage_renameObjects((id,), (no_extension,))

for id in context.objectIds():
    s, l = 'copy_of_', len('copy_of_')
    if id[:l]==s:
        print 'renaming '+id+' to '+id[l:]
        context.manage_renameObjects((id,), (id[l:],))

return printed

Explanation:
delete all files ending w/ .lck

delete all files w/o extension but have an extension, assumption files
with extensions are always newer.

make copy of files (they will now have copy_of_xxxx)

rename files that have extensions to files that dont have extensions

rename all copy_of files to ids that dont have that on them.


Comments:

No Comments