Computers & Internet Logo

Related Topics:

Posted on May 12, 2008

Pyton Programming Please help me describe the following code: a) The structure b) The overall feature it might provide c) The mechanisms used to provide the feature. class Config(object): validKeys = [ 'CompanyName', 'ExternalName', 'Hostname', 'Domain', 'SambaDomain' ] def __init__(self): profileLocator = open(os.path.join(Settings.BaseDir, 'currentProfile')) profileName = profileLocator.read().replace(' ', '').strip() self.configFile = os.path.join(Settings.BaseDir, 'profiles', profileName) self.cache = {} self.cacheAge = 0 self.maxAge = 300 def __getattr__(self, name): if name in self.validKeys: configAge = os.stat(self.configFile).st_mtime now = time.time() #Setup conditions stillValid = self.cacheAge == configAge tooOld = (now self. cacheAge) > self.maxAge if self.cache and stillValid and not tooOld: return self.cache[name] # Read the file (full unbuffered) cfo = open(self.configFile, 'rt') self.cacheAge = os.stat(self.configFile).st_mtime data = cfo.read() cfo.close() d = {} exec data in d self.cache = d return self.cache[name] else: object.__getattr__(self, name, value)

1 Answer

Anonymous

Level 1:

An expert who has achieved level 1.

Hot-Shot:

An expert who has answered 20 questions.

Corporal:

An expert that has over 10 points.

Mayor:

An expert whose answer got voted for 2 times.

  • Contributor 71 Answers
  • Posted on Jul 30, 2008
Anonymous
Contributor
Level 1:

An expert who has achieved level 1.

Hot-Shot:

An expert who has answered 20 questions.

Corporal:

An expert that has over 10 points.

Mayor:

An expert whose answer got voted for 2 times.

Joined: Aug 12, 2007
Answers
71
Questions
0
Helped
14573
Points
93

Could you give me more info plz

Ad

Add Your Answer

×

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

93 views

Ask a Question

Usually answered in minutes!

Top Computers & Internet Experts

ADMIN Andrew
ADMIN Andrew

Level 3 Expert

73781 Answers

ADMIN Eric
ADMIN Eric

Level 3 Expert

42220 Answers

Brad Brown

Level 3 Expert

19190 Answers

Are you a Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...