def generate(self): sysConf = SYSConf() if self.path and LocalOperation.exist(self.path): Log.fatal(Status["STAT_GPM_CONF_EXIST"]) #key prompt default verify sections = [("name", "project name", self.name or None, VerifyName), ("language", "project language", self.language or None, VerifyName), ("author", "author name", self.author or sysConf.author, None), ("version", "initial version", self.version or 0.1, None), ("email", "author email", self.email or sysConf.email, VerifyEmail), ("description", "project description", self.description or "", None), ("git_url", "git url[[email protected]:name/project.git]", sysConf.git_url or None, None)] for section in sections: while(1): self._content[section[0]] = gets("Input %s" % section[1], section[2]) if section[3] and not self._content[section[0]]: Log.warn(Status["STAT_INPUT_EMPTY"] % section[0]) continue elif section[3] and not VerifyName(self._content[section[0]]): Log.warn(Status["STAT_INPUT_INVALID"] % section[0]) continue else: break pkg_path = os.path.join(LocalOperation.pwd(), self.name) self._path = os.path.join(pkg_path, GPM_YML) self.write(self._path, self._content)
def generate(self): sysConf = SYSConf() if self.path and LocalOperation.exist(self.path): Log.fatal(Status["STAT_GPM_CONF_EXIST"]) #key prompt default verify sections = [("name", "project name", self.name or None, VerifyName), ("language", "project language", self.language or None, VerifyName), ("author", "author name", self.author or sysConf.author, None), ("version", "initial version", self.version or 0.1, None), ("email", "author email", self.email or sysConf.email, VerifyEmail), ("description", "project description", self.description or "", None), ("git_url", "git url[[email protected]:name/project.git]", sysConf.git_url or None, None)] for section in sections: while (1): self._content[section[0]] = gets("Input %s" % section[1], section[2]) if section[3] and not self._content[section[0]]: Log.warn(Status["STAT_INPUT_EMPTY"] % section[0]) continue elif section[3] and not VerifyName(self._content[section[0]]): Log.warn(Status["STAT_INPUT_INVALID"] % section[0]) continue else: break pkg_path = os.path.join(LocalOperation.pwd(), self.name) self._path = os.path.join(pkg_path, GPM_YML) self.write(self._path, self._content)
def __init__(self, config = None, path = None): self.__config = config self.__path = path or LocalOperation.pwd()