logical puzzle: how to generate reasonable archive file names fromfile and directory names

Discussion in 'Python' started by fBechmann, Jun 10, 2004.

  1. fBechmann

    fBechmann Guest

    I'm writing a module to convert between filesystem nodes
    (directory,file) and various archives (gz, zip, tgz).

    For this I want to automatically create reasonable file names for the
    archives where these file names depend from the type of the file system
    node to be archived and from the type of the archive to be created.

    I want the following transformations to take place:

    Dir
    abc =(gz)=> *not allowed*
    =(zip,tgz)=> abz.zip,abc.tgz
    abc.XY =(gz)=> *not allowed*
    =(zip,tgz)=> abc.XY.zip,abc.XY.tgz

    File
    abc =(gz)=> abc.gz
    =(zip,tgz)=> abz.zip,abc.tgz
    abc.ext =(gz)=> abc.ext.gz
    =(zip,tgz)=> abc.zip,abc.tgz

    For the decision to remove the extension from the file or directory this
    gives me the following table:

    gz zip,tgz
    Dir *n.a.* no
    File no yes

    I have the classes Dir, File, ArchiveGZ and MultiFileArchive (base class
    for ArchiveTGZ and ArchiveZIP, which share behaviour w/ respect to that
    naming transformation).

    I've found a way which looks quite cruel (and which I'll post later), so
    I have the hope that someone here finds a nice snippet of code for this.

    thx in advance
    fBechmann, Jun 10, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. anastasia
    Replies:
    4
    Views:
    17,517
    atalas
    Apr 18, 2008
  2. =?Utf-8?B?YnNtYWxpaw==?=

    Image.FromFile

    =?Utf-8?B?YnNtYWxpaw==?=, Dec 29, 2004, in forum: ASP .Net
    Replies:
    8
    Views:
    535
    Scott Allen
    Dec 29, 2004
  3. Darrel
    Replies:
    4
    Views:
    372
    Rob Meade
    Jul 20, 2006
  4. SpreadTooThin

    array tofile fromfile tosocket? fromsocket?

    SpreadTooThin, Oct 3, 2006, in forum: Python
    Replies:
    2
    Views:
    236
    SpreadTooThin
    Oct 4, 2006
  5. Joe Schmo
    Replies:
    0
    Views:
    447
    Joe Schmo
    Apr 29, 2012
Loading...

Share This Page