DictObjSys (DOS): Dictionary Objects System V.0.0.1 (2004 Oct 26)

Discussion in 'Python' started by RDJ, Oct 26, 2004.

  1. RDJ

    RDJ Guest

    === This is a AoooAoooA project (^_^) ===

    DictObjSys (DOS): Dictionary Objects System V.0.0.1 (2004 Oct 26)

    Copyright (C) 2004 RDJ

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


    TABLE OF CONTENTS
    *****************

    _REFERENCES
    _FILES
    _RUN_DOS


    _REFERENCES
    ************

    Redirect: AoooAoooA.too.it
    ____Site: it.geocities.com/dawjde/AoooAoooA.html
    ___Email: (OBJECT: [AoooAoooA] your object)


    _FILES
    ******

    DictObjSys/DOS.py...........library
    DictObjSys/GNU_LGPL.txt.....GNU LIBRARY GENERAL PUBLIC LICENSE
    DictObjSys/README.txt.......this file


    _RUN_DOS
    ********

    DOS is a library but you can run a test:

    python DOS.py


    Appear:

    This is a test:
    1-2
    ['three.a', 'three.b']
    1-2-3b


    It is OK! Now view the source code...

    #
    # Class
    #

    class DOS:
    def __init__(self):
    self.value = None
    self.dict = {}

    def get(self,path):
    dos = self.getDOS(path)
    if dos == None:
    return None
    else:
    return dos.value

    def getDOS(self,path):
    pl = path.split('/')
    dos_tmp = self
    try:
    for r in pl:
    dos_tmp = dos_tmp.dict[r]
    return dos_tmp
    except KeyError:
    return None

    def keys(self):
    return self.dict.keys()

    def set(self,path,value):
    pl = path.split('/')
    dos_tmp = self
    for r in pl:
    if dos_tmp.dict.has_key(r) == False:
    dos_tmp.dict[r] = DOS()
    dos_tmp = dos_tmp.dict[r]
    dos_tmp.value = value;
    #
    # Main
    #

    if __name__ == '__main__':
    print 'This is a test:'
    dos = DOS()
    dos.set('one/two','1-2')
    dos.set('one/two/three.a','1-2-3a')
    dos.set('one/two/three.b','1-2-3b')
    print dos.get('one/two')
    print dos.getDOS('one/two').keys()
    print dos.get('one/two/three.b')
    RDJ, Oct 26, 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. Replies:
    0
    Views:
    689
  2. Larry Kim
    Replies:
    0
    Views:
    916
    Larry Kim
    Sep 2, 2003
  3. Akmal B. Chaudhri
    Replies:
    0
    Views:
    706
    Akmal B. Chaudhri
    Jul 11, 2004
  4. Brett C.
    Replies:
    7
    Views:
    342
    Michael Hudson
    Feb 26, 2004
  5. Mike Stok
    Replies:
    3
    Views:
    96
    Mike Stok
    Oct 5, 2004
Loading...

Share This Page