view upmana/validate.py @ 113:f91b70c46908 alpha

Traipse Alpha 'OpenRPG' {091009-01} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary: {091006} 00: Adds Bookmarks (Alpha) with cool Smiley Star and Plus Symbol images! 03: Changes made to the map for increased portability. SnowDog has changes planned in Core, though. Added an initial push to the BCG. Not much to see, just shows off how it is re-writing Main code. {091008} 00: Fix to remote admin commands 01: Minor fix to texted based server, works in /System/ folder Some Core changes to gametree to correctly disply Pretty Print, thanks David! {091009} 00: Fix to Splitter Nodes not being created. Plugin Control panel works with images now Fix to massive amounts of images loading; from Core 01: Version Number
author sirebral
date Fri, 09 Oct 2009 23:28:33 -0500
parents 65c212e9a5b4
children 496dbf12a6cb
line wrap: on
line source

# file: config_files.py
#
# Author: Todd Faris (Snowdog)
# Date:   5/10/2005
#
# Misc. config file service methods
#

from orpg.dirpath import dir_struct
import os

class Validate:
    def __init__(self, userpath=None):
        if userpath is None:
            userpath = dir_struct["home"] + os.sep + 'upmana' +os.sep
        self.__loadUserPath = userpath

    def config_file(self, user_file, template_file):
        #STEP 1: verify the template exists
        if (not os.path.exists(dir_struct["template"] + template_file)):
            return 0

        #STEP 2: verify the user file exists. If it doesn't then create it from template
        if (not os.path.exists(self.__loadUserPath + user_file)):
            default = open(dir_struct["template"] + template_file,"r")
            file = default.read()
            newfile = open(self.__loadUserPath + user_file,"w")
            newfile.write(file)
            default.close()
            newfile.close()
            return 2  #returning 2 (True) so calling method will know if file was created

        #STEP 3: user file exists (is openable) return 1 indicating no-create operation required
        else: return 1

    def ini_entry(self, entry_name, ini_file):
        pass

validate = Validate()