Mercurial > traipse_dev
comparison orpg/tools/validate.py @ 0:4385a7d0efd1 grumpy-goblin
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
author | sirebral |
---|---|
date | Tue, 14 Jul 2009 16:41:58 -0500 |
parents | |
children | c54768cffbd4 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4385a7d0efd1 |
---|---|
1 # file: config_files.py | |
2 # | |
3 # Author: Todd Faris (Snowdog) | |
4 # Date: 5/10/2005 | |
5 # | |
6 # Misc. config file service methods | |
7 # | |
8 | |
9 import orpg.dirpath | |
10 import os | |
11 | |
12 class Validate: | |
13 def __init__(self, userpath=None): | |
14 if userpath is None: | |
15 userpath = orpg.dirpath.dir_struct["user"] | |
16 self.__loadUserPath = userpath | |
17 | |
18 def config_file(self, user_file, template_file): | |
19 #STEP 1: verify the template exists | |
20 if (not os.path.exists(orpg.dirpath.dir_struct["template"] + template_file)): | |
21 return 0 | |
22 | |
23 #STEP 2: verify the user file exists. If it doesn't then create it from template | |
24 if (not os.path.exists(self.__loadUserPath + user_file)): | |
25 default = open(orpg.dirpath.dir_struct["template"] + template_file,"r") | |
26 file = default.read() | |
27 newfile = open(self.__loadUserPath + user_file,"w") | |
28 newfile.write(file) | |
29 default.close() | |
30 newfile.close() | |
31 return 2 #returning 2 (True) so calling method will know if file was created | |
32 | |
33 #STEP 3: user file exists (is openable) return 1 indicating no-create operation required | |
34 else: return 1 | |
35 | |
36 def ini_entry(self, entry_name, ini_file): | |
37 pass |