473,387 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

wrapper classes question..


Hi i made a wrapper class for handling file and dir operations and i wonder,
*whats*the*performance*penalty*for*making*such*wra pper*classes?*is it ok to
make a lot of these wrappers? here*it*is:

#################
import os

class File(object):

****#access*modes
****F_OK*=*os.F_OK,
****W_OK*=*os.W_OK,
****R_OK*=*os.R_OK,
****X_OK*=*os.X_OK
*****
********
****def*__init__(s,pathToFile):

*s.path*=*pathToFile
*s.name*=*os.path.basename(s.path)
*s.dirName*=*os.path.dirname(s.path)
*#s.size*=*path.getsize(s.path)

****
****def*size(s):
*return*os.path.getsize(s.path)
****
****def*open(s,mode='r'):
*return*open(s.path,mode)

****def*openw(s):
*return*open(s.path,'w')

****def*access(s,mode):
*return*os.access(s.path,mode)
****
****def*abspath(s):
*return*os.path.abspath(s.path)

****def*getatime(s):
*return*os.path.getatime(s.path)
****
****def*getctime(s):
*return*os.path.getctime(s.path)
****
****def*isabs(s):
*return*os.path.isabs(s.path)

****def*isfile(s):
*return*os.path.isfile(s.path)

****def*isdir(s):
*return*os.path.isdir(s.path)

****def*ext(s):
*return*os.path.splitext(s.path)[1]

****def*stat(s):
*return*os.stat(s.path)
****
****def*access(s,mode):
*return*os.access(s.path,mode)

def chdir(path) : os.chdir(path)

def cwd() : return os.getcwd()

def chmod(path,mode): return os.chmod(path,mode)

def chown(path,uid,gid): os.chown(path,uid,gid)

def ln(src,dest): os.symlink(src,dest)

def ls(path): return os.listdir(path)

def mkdir(path,rec=False,mode = 0777) :
****if*not*rec:
********os.mkdir(path,mode)
****else:
*os.makedirs(path,mode)

def rm(path):****os.remove(path)

def rename(old,new): os.rename(old,new)

def rmdir(path): os.rmdir(path)

def xremove(path) :
****'just*unix'
****os.system('rm*-rf*%s'*%*path)

def utime(path,times=None):
****'set*times*of*a*file\
****times*=*tuple*like*(atime,ctime)*'
****os.utime(path,times)

if __name__ == '__main__':
****
****f*=*File('/tmp')
****print*f.isfile()
****print*f.isdir()
****print*f.size()
****print*ls('/tmp')

Jul 18 '05 #1
0 1087

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Egil M?ller | last post by:
Is there any way to create transparent wrapper objects in Python? I thought implementing __getattribute__ on either the wrapper class or its metaclass would do the trick, but it does not work for...
1
by: MB | last post by:
I am trying to work out why .NET 1.1 SP1 (XSD.exe) cannot generate wrapper classes for LandXML 1.0 or 1.1 (http://www.landxml.org/spec.htm) and yet .NET 2.0 (BETA 1) can for LandXML 1.0. The...
15
by: Steve Richfield | last post by:
To All, First, some of your replies to me have been posted through DevelopersDex, and these are NOT posted on USENET for the world to see. DevelopersDex appears to be trying to hijack USENET,...
9
by: WithPit | last post by:
I am trying to create an Managed C++ Wrapper around an unmanaged library which contains C++ code. Some of the unmanaged methods returns an returntype which is of the abstract base type (for...
3
by: WithPit | last post by:
I am trying to create an managed wrapper but have some problems with it by using abstract classes. In my unmanaged library code i had the following three classes with the following hierarchy ...
4
by: Gary Bond | last post by:
Hi All, Can anybody point me to some 'how-to' documentation, tutorials, etc as to how to write a shrink/protect wrapper for .Net exes/dlls, (like the Shrinkwrap product for instance). I have...
0
by: Kurt | last post by:
I have an MFC static lib which exports som classes, it still needs to be available to MFC apps and now C# apps as well. For C# I am creating a wrapper dll that will link in the library. My question...
9
by: Julien Biezemans | last post by:
Hi! Here is the problem: I'd like to restrict local filesystem stream operations to one directory just like a root jail. fopen('/file.bin') would actually open /some/path/file.bin. One goal...
1
by: mschuck | last post by:
Here is the scenario I'm trying to make work. I've got 2 managed C++ classes, each of which wrappes an unmanaged C++ class, kind of like so: __nogc class UnmanagedClassA { public: void...
4
by: a_agaga | last post by:
Hi! Do you know different alternatives to convert exceptions in many methods of some wrapper classes. User -Wrapper classes -LibraryClasses -... Wrapper classes catch an exception of only...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.