Mistři v programování na #hovnokod

Python #458

def MonthsListGen(*args, **kwargs):
	from datetime import datetime

	if kwargs.has_key('month') and kwargs.has_key('year'):
		return "%s-%s"%(kwargs['year'], "0%d"%kwargs['month'] if kwargs['month']<10 else str(kwargs['month']))

	if kwargs.has_key('date'): return MonthsListGen(year = kwargs['date'].year, month = kwargs['date'].month)

	if kwargs.has_key('decodeName'): return MONTH_NAMES[int(kwargs['decodeName'].split('-')[1])]
	if kwargs.has_key('decodeYear'): return int(kwargs['decodeYear'].split('-')[0])
	if kwargs.has_key('startDate') and kwargs.has_key('endDate'):
		startDate = kwargs['startDate']
		endDate = kwargs['endDate']
		monthList = []
		if startDate.year < endDate.year:
			startDate1 = startDate
			endDate1 = datetime.strptime('%d.%d.%d'%(DAYS_IN_MONTH[12], 12, startDate1.year) , '%d.%m.%Y')
			monthList = MonthsListGen(startDate = startDate1, endDate = endDate1)

			startDate2 = datetime.strptime('%d.%d.%d'%(1, 1, startDate1.year+1) , '%d.%m.%Y')
			endDate2 = endDate
			monthList += MonthsListGen(startDate = startDate2, endDate = endDate2)
			return monthList
		if startDate.year == endDate.year:
			monthRange = range(startDate.month, endDate.month+1)
			year = startDate.year
			for monthNo in monthRange:
				monthList.append(MonthsListGen(year = year, month = monthNo))
			return monthList
	return False

HovnoKod,