something like this....

def convert(source, destination, c='xxx'):
    links=[]
    actions=[]
    for file in source folder (traverse tree):
        if not file.endswith('.html'):
            copy file under destination/static (and create missing
folders)
            links.append(file)
    for file in source folder (traverse tree):
        if file.endswith('.html'):
            actions.append(file[:-5])
            data = open(file) and read
            for link in links:
                data=data.replace(link,URL('static',link))
            write data in file under destination/views/c
        data='\n'.join('def %s():return dict()' % a for a in actions)
        write data in file under destination/controllers/c.py

Massimo


On Nov 24, 2:52 pm, Michele Comitini <[email protected]>
wrote:
> Is this a oneshot?
> Else I would go scons
> (http://www.scons.org/doc/production/HTML/scons-user/index.html)
>
> 2010/11/24 mart <[email protected]>:
>
> > can you provide a sample folder + contents?
>
> > Mart :)
>
> > On Nov 24, 3:05 pm, mdipierro <[email protected]> wrote:
> >> I have a challanage:
>
> >> write a script that takes a folder that contains a static html file
> >> and converts it into an HTML site.
>
> >> 1) moves all non .html files into static/
> >> 2) moves all .html files into views/xxx/
> >> 3) creates a controllers/xxx.py and for each yyy.html file add an
> >> action
>
> >> def yyy(): return dict()
>
> >> 4) loop over all .html files and fixes all the URL to {{=URL(...)}}}
>
> >> OPTIONAL:
> >> 5)
> >> If all .html files start with a similar header and footer, tried to
> >> identify them, moves "<header>{{include}}<footer>" into views/
> >> layout.html and rewrite the html files to {{extend 'layout.html'}}
>
> >> The original folder and 'xxx' should be uer defined. This could be
> >> added to the wizard.
>
> >> Massimo
>
>

Reply via email to