Hi all,
I am new to Python and this mailing list. I wondered if someone would be 
kind enough to give me a basic python skeleton to achieve the following.

Many thanks in advance
Majid

---------------------------------


      Here are the assumptions:

1. we have a list.txt file with entries like:

        /dists/dapper/Release.gpg
        /dists/dapper/main/binary-i386/Release
        /dists/dapper/restricted/binary-i386/Release
        /doc/install/manual/example-preseed.txt.gz
        /doc/install/manual/en/apa.html
        /doc/install/manual/en/apas01.html

    2. The files referenced in the list file (and many other files) are
    in C:\source\ directory and subdirectories as defined in the list
    file - e.g. for the first entry above we have this file:

        C:\source\dists\dapper\Release.gpg

    3. We want only the files listed in the list file to be copied to
    D:\target\ keeping the same directory structure. So for the first
    entry we want to have this file:

        D:\target\dists\dapper\Release.gpg

    4. If a file listed in the list file is not found in the source, we
    want an entry to be added to C:\py\missing.txt (by the way the
    python script doing the job could be in this directory too - i.e.
    C:py\packagemaker.py - also the list file is here too: C:\py\list.txt)


      Here is a possible logic for the script:

    1. Open the list (C:\py\list.txt).
    2. Until the end of the file
       3. Read a line from list.txt (e.g. '/dists/dapper/Release.gpg')
       4. Change forward slashes to back slashes (e.g.
    '\dists\dapper\Release.gpg')
       5. Add 'C:\source' to the string  (e.g.
    'C:\source\dists\dapper\Release.gpg')
       6. If the file exists in the source folder
          7. Copy the file from the source frolder to the target folder
    (e.g. copy C:\source\dists\dapper\Release.gpg to
    D:\target\dists\dapper\Release.gpg)
       8. Else
          9. Add the name of the missing file to missings.txt
    10. End of loop


      Possible uses of the script?

I have copied the contents of an ubuntu dvd to my hard drive 
(C:\source\). It contains many files and directories totaling 3.45 GB. I 
have also downloaded the .list files for the server and alternate instal 
iso images:

    ubuntu-6.06.1-server-i386.list and ubuntu-6.06.1-alternate-i386.list

The ordinary 'desktop' install cd/dvd requires at least 512 MB or ram 
which I don't have. It is also impossible to download the 700 MB iso 
images for the server / alternate CDs as I only have a dial-up 
connection. To make the situation worse, these CDs could not be found in 
local stores in my city. So the only option left is making the server 
and alternate CDs myself. This is why I need the script.


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to