Exemplo n.º 1
0
def readDefault():
	if not os.path.exists(__DEFAULT_LOC) or not os.path.isfile(__DEFAULT_LOC):
		Out.errorMessage(ErrorMessage.SKEL_IO_ERROR_DEFAULT)
		raise GeneratorException()
	try :
		readSkel(__DEFAULT_LOC)
	except :
		Out.errorMessage(ErrorMessage.SKEL_IO_ERROR_DEFAULT)
		raise GeneratorException()
Exemplo n.º 2
0
def readSkeletonFile(skel : str):
	if skel is None :
		raise GeneratorException(message='Skeleton file must not be None')

	if not os.path.isfile(skel):
		Out.errorMessage(message=ErrorMessage.CANNOT_READ_SKEL,file=skel)
		raise GeneratorException()

	Out.writeln(message=ErrorMessage.READING_SKEL, *skel )

	try:
		file = open(skel)
		readSkel(skel)
	except :
		Out.errorMessage(ErrorMessage.SKEL_IO_ERROR)
		raise GeneratorException()
Exemplo n.º 3
0
def readSkel(skel):
	global lines
	lines = []
	selection = ''
	for ln in open(skel):
		if ln.startswith('---') :
			lines.append(selection)
			selection = ''
		else :
			selection += __NL
			selection += ln

	if selection :
		lines.append(selection)

	if len(lines) != __SIZE :
		Out.errorMessage(message=ErrorMessage.WRONG_SKELETON);
		raise GeneratorException()
Exemplo n.º 4
0
def setDir(path : str) :
	"""
	Метод устанавливает папку
	Если указаный пусть файл будет брошено исключение
	Если же такой папки не существует она будет создана,
	если произошла ошибка при создании папки будет брошено исключение.
	:param path: пусть папки
	:raise: GeneratorException()
	"""
	global __directory
	if os.path.isdir(path) :
		__directory  = path
		# print(path)
	elif os.path.isfile(path) :
		# print("Error: \""+path+"\" is not a directory.")
		Out.errorString("Error: \""+path+"\" is not a directory.")
		raise GeneratorException()
	else :
		try :
			os.makedirs(path)
			__directory = path
		except Exception:
			Out.errorMessage("Error: couldn't create directory \""+path+"\"")
			raise GeneratorException()