Programming Tools
Problem for Programming Tools
Generic problem for all Programming Tools

Pyton Programming




By Mirandza on May 12, 2008

" "
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)


Solution #1

posted on Jul 30, 2008
Not Rated)

femster

Rank: Guru 
Rating: 85%, 71 votes
could you give me more info plz
Was this helpful?
Yes
No

Popular Solutions for Programming Tools


Questions and Unsolved Problems for Programming Tools


Answer
where can I get a customer tool disk for a sharp xa-a41s??

Answer
Is there an software program or an installation manual for a notifier 320 fire panel?

Answer
my friend gave me his computer and not the pass. i moved away. forgot to ask him. im a gamer i need... (More)

Answer
hi i have a impulse DAMBUSTER fruit machine and dont know how to stop it paying out more than i put... (More)

Answer
photoshop 7.0 installation fails with the error message: "An error occurred during the move... (More)


Didn't find what you were looking for?

Describe your problem:

Select a Category:







Ask our Experts

 

Solve Your Problem Now!
Chat Live with an Expert
Chat Now
Top Programming... Experts



Top Computer & Laptop Repair
(877) 934-6198
Send your laptop to us and we will diagnose the...
A+ Rated Oceanside Computer Sales & Service, LLC

(877) 729-0812
We connect to your computer over the Internet to...
Remote Repair



       
Solve Your Problem Now!
Chat Live with an Expert
Chat Now

Insert Link
Insert Image
Insert You-Tube clip
Insert List
Insert List
Spell Check

What is this?



Select