def drawBottomShape(draw, image, mainColor, instrument): fontSize = 40 buyOrder = instrument.buyOrder selOrder = instrument.selOrder drawTextAtMiddle(1810, draw, buyOrder.numOfRealTrades, 1530, fontSize, mainColor) drawPositionedText(draw, 620, buyOrder.volumeOfRealTrades, 1610, fontSize - 5, mainColor) drawTextAtMiddle(1810, draw, buyOrder.numOfLegalTrades, 1670, fontSize, mainColor) drawPositionedText(draw, 620, buyOrder.volumeOfLegalTrades, 1760, fontSize - 5, mainColor) drawTextAtMiddle(300, draw, selOrder.numOfRealTrades, 1530, fontSize, mainColor) drawPositionedText(draw, 250, selOrder.volumeOfRealTrades, 1610, fontSize - 5, mainColor) drawTextAtMiddle(300, draw, selOrder.numOfLegalTrades, 1670, fontSize, mainColor) drawPositionedText(draw, 200, selOrder.volumeOfLegalTrades, 1760, fontSize - 5, mainColor) drawTextAtMiddle(1080, draw, persian.enToPersianNumb(instrument.yesterdayPrice), 1350, fontSize, mainColor) drawTextAtMiddle(250, draw, persian.enToPersianNumb(instrument.minValiPrice), 1350, fontSize, mainColor) drawTextAtMiddle(1900, draw, persian.enToPersianNumb(instrument.maxValidPrice), 1350, fontSize, mainColor)
def cdp(st): #dat_time = dateparser.parse(u'Sun, 11 Mar 2017 10:22:50') dat_time = dateparser.parse(st) pdt = jdatetime.datetime.fromgregorian(datetime=dat_time) pds = pr.enWeekdayToPersian(pr.enMonthToPersian( pr.enToPersianNumb(pdt.strftime("%H:%M:%S ,%a %d %b %Y"))), full=True) return pds
def salary(request): form = Salary() if request.method == 'POST': form = Salary(request.POST) if form.is_valid(): earn = 0 degree_additional = { 'ba': 1000000, 'ma': 1500000, 'phd': 2400000, } degree_format = { 'ba': 'لیسانس', 'ma': 'فوق لیسانس', 'phd': 'دکنری', } code = form.cleaned_data.get('teach_code') teacher = Teacher.objects.filter(tid=code).first() delta = relativedelta(date.today(), teacher.hire_date) days = (delta.years * 365) + (delta.months * 30) + delta.days earn = (earn + days * 15000) + degree_additional[teacher.education_degree] teacher_info = dict( id=teacher.id, full_name=teacher.user.first_name + " " + teacher.user.last_name, degree=degree_format[teacher.education_degree], experience=teacher.experience, earn=persian.enToPersianNumb(f"{earn:,}"), ) return render(request, 'edu/salary.html', context={ 'result': teacher_info, 'date': get_date_time() }) else: return render(request, 'edu/salary.html', context={ 'form': form, 'date': get_date_time() }) else: return render(request, 'edu/salary.html', context={ 'form': form, 'date': get_date_time(), 'msg': 'برای دسترسی باید وارد شوید' })
def drawUpperSqare(draw, image, mainColor, instrument): w = 0 initial_text_1 = " ارزشمعاملات" initial_text_2 = " حجممبنا" initial_text_3 = " ورود پول حقیقی" initial_text_4 = " حجم" initial_text_5 = " قیمت پایانی" initial_text_6 = " آخرین قیمت" text = initial_text_1 + persian.enToPersianNumb(" : " + instrument.tradeValue) drawTextAtMiddle(image.size[0], draw, text, 380, 35, mainColor) text = initial_text_2 + persian.enToPersianNumb(" : " + instrument.basevVolume) drawTextAtMiddle(image.size[0], draw, text, 455, 35, mainColor) drawTextAtMiddle( image.size[0], draw, initial_text_3 + persian.enToPersianNumb(" : " + instrument.realMoneyIncome), 520, 35, mainColor) drawTextAtMiddle( image.size[0], draw, initial_text_4 + persian.enToPersianNumb(" : " + instrument.lastPrice), 605, 35, mainColor) w = drawPositionedText(draw, 600, initial_text_5, 680, 35, mainColor) w = drawPositionedTextInLine(draw, w, " : ", 680, 35, mainColor) w = drawPositionedTextInLine( draw, w, persian.enToPersianNumb(" (" + instrument.finalPricePrercent + "%) "), 685, 35, mainColor) drawPositionedTextInLine( draw, w, persian.enToPersianNumb(" " + instrument.finalPrice + " "), 683, 35, mainColor) w = drawPositionedText(draw, 600, initial_text_6, 745, 35, mainColor) w = drawPositionedTextInLine(draw, w, " : ", 745, 35, mainColor) w = drawPositionedTextInLine( draw, w, persian.enToPersianNumb(" (" + instrument.lastPricePercent + "%) "), 750, 35, mainColor) drawPositionedTextInLine( draw, w, persian.enToPersianNumb(" " + instrument.lastPrice + " "), 748, 35, mainColor)
def to_persian(text): return persian.enToPersianNumb(text)
def reqPrase(): name, theme = parseInputArgs() f = open('dataFile.json', "r", encoding='utf-8') data = json.load(f) instrument = TradeVariables() instrument.symbolname = str(data['Name']) instrument.symbolFullName = str(data['Title']) instrument.symbolCondition = " " + str(data['StatusDescription']) + " " instrument.minValiPrice = str(data['MinValidPrice']) instrument.maxValidPrice = str(data['MaxValidPrice']) instrument.yesterdayPrice = str(data['YesterdayPrice']) instrument.finalPrice = str(data['LastPrice']) instrument.basevVolume = str(int(data['BaseVolume']) / 1000000) + "M" instrument.tradeValue = str(int(data['Cost'] / 1000000000)) + "B" instrument.lastPrice = str(data['CurrPrice']) instrument.volume = str(int(data['Volume']) / 1000000) + "M" ####################### instrument.realMoneyIncome = persian.enToPersianNumb( str(data['InputMoney'])) instrument.lastPricePercent = persian.enToPersianNumb( percentTokenize(str(data['DiffCurrPrice']))) instrument.finalPricePrercent = persian.enToPersianNumb( percentTokenize(str(data['DiffLastPrice']))) ####################### for i in range(0, 3): instrument.selOrder.amount.append( persian.enToPersianNumb(str(data['Q'][i]['CountBid']))) instrument.selOrder.price.append( persian.enToPersianNumb(str(data['Q'][i]['PriceBid']))) instrument.selOrder.volume.append( persian.enToPersianNumb(str(data['Q'][i]['VolBid']))) instrument.buyOrder.amount.append( persian.enToPersianNumb(str(data['Q'][i]['CountBuy']))) instrument.buyOrder.volume.append( persian.enToPersianNumb(str(data['Q'][i]['VolBuy']))) instrument.buyOrder.price.append( persian.enToPersianNumb(str(data['Q'][i]['PriceBuy']))) instrument.buyOrder.volumeOfRealTrades = persian.enToPersianNumb( str(data['C']['VolumeAskIndv'])) instrument.buyOrder.volumeOfLegalTrades = persian.enToPersianNumb( str(data['C']['VolumeAskNoneIndv'])) instrument.buyOrder.numOfRealTrades = persian.enToPersianNumb( str(data['C']['CountAskIndv'])) instrument.buyOrder.numOfLegalTrades = persian.enToPersianNumb( str(data['C']['CountAskNoneIndv'])) instrument.selOrder.volumeOfRealTrades = persian.enToPersianNumb( str(data['C']['VolumeBidIndv'])) instrument.selOrder.volumeOfLegalTrades = persian.enToPersianNumb( str(data['C']['VolumeBidNoneIndv'])) instrument.selOrder.numOfRealTrades = persian.enToPersianNumb( str(data['C']['CountBidIndv'])) instrument.selOrder.numOfLegalTrades = persian.enToPersianNumb( str(data['C']['CountBidNoneIndv'])) return instrument, theme, name
def localize_date(date): jalali = khayyam.JalaliDatetime.from_datetime(date).strftime( u'%A، %d %B %Y') return persian.enToPersianNumb(jalali.encode('utf-8')).decode('utf-8')
# encoding: utf-8 from persian import enToPersianNumb assert(enToPersianNumb('1234567890.1234567890') == '۱۲۳۴۵۶۷۸۹۰.۱۲۳۴۵۶۷۸۹۰') , 'Not Equal' print 'Done~~!'
def __str__(self): return self.student.user.first_name + " " + self.courses.course_name + " " + str( persian.enToPersianNumb(self.final_grade))
def __str__(self): return self.user.first_name + " " + self.user.last_name + " " + str( persian.enToPersianNumb(self.sid))
def experience(self): delta = relativedelta(date.today(), self.hire_date) year = persian.enToPersianNumb(str(delta.years)) month = persian.enToPersianNumb(str(delta.months)) days = persian.enToPersianNumb(str(delta.days)) return "{} سال و {} ماه و {} روز".format(year, month, days)