def triggerUpdate(self):
self.caluser.updateProfile(self.inp)
self.Root.toolbar.title = "CalTrac - %s" % date.isoformat(date.today())
self.Root.nameLbl.text = 'About ' + self.caluser.getDict('name')
self.Root.heightLbl.text = 'Height: ' + self.caluser.getDict('height')
self.Root.weightLbl.text = 'Weight: ' + self.caluser.getDict('weight')
self.Root.ageLbl.text = 'Age: ' + self.caluser.getDict('age')
if self.caluser.getDict('preg') == '0':
self.Root.genderLbl.text = 'Gender: ' + self.caluser.getDict('gender')
self.Root.kcalTxt.text = 'Kcal target: ' + str(int(float(self.caluser.getDict('bmr'))))
else:
self.Root.genderLbl.text = 'Gender: %s (Pregnant)' % self.caluser.getDict('gender')
self.Root.kcalTxt.text = 'Kcal target: ' + str(int(float(self.caluser.getDict('bmr')))+350)
self.Root.ratingLbl.text = 'Rating: ' + self.caluser.getDict('rating')
self.nav_drawer.ids['nameBtn'].text = self.caluser.getDict('name')
self.Profile.ids['profileToolbar'].left_action_items = [['arrow-left', lambda x: self.changeScreens('Root')]]
python类isoformat()的实例源码
def test_datetime(self):
self.assertEqual(self.dump_and_load(self.ts), self.ts.isoformat())
def test_date(self):
date = self.ts.date()
self.assertEqual(self.dump_and_load(date), date.isoformat())
def test_time(self):
time = self.ts.time()
self.assertEqual(self.dump_and_load(time), time.isoformat())
def listDelete(self,delta):
l = c.execute("SELECT rowid, * FROM foods WHERE date = ?", (date.isoformat(date.today() - timedelta(delta)),)).fetchall()
self.deleteTable.clear_widgets()
for it in l:
self.deleteTable.add_widget(DelBtn(text='%s - x%s' % (it[1],str(it[4]).replace('.0','')),
secondary_text='kcal: %s' % str(it[3]).replace('.0',''),id = str(it[0])))
def fmt_date(date):
return "%s, week %d, %s" % (
date.isoformat(),
date.isocalendar()[1],
date.strftime("%A, %B"))
def test_should_coerce_date(self):
date_ = date.today()
result = api.resource.resolve_value(date_)
self.assertEqual(result, date.isoformat(date_))
def __init__(self, args, optimizer, name, extra_msg=''):
self.iteration = 0
self.sum_loss = 0
self.sum_acc = 0
self.sum_mean_diff = 0
self.sum_max_diff = 0
self.current_section = ''
self.optimizer = optimizer
# setup according to arguments
self.name = name if name is not '' else 'signdist'
self.out_file = "{}_{}".format(date.isoformat(date.today()), self.name)
self.log_file = "{}.log".format(self.out_file)
# write config to head of the log file
self.write_config(args, extra_msg)
def write_config(self, args, extra_msg):
with open(self.log_file, 'a+') as f:
self._comment("=" * 40, f)
self._comment("{} initiated at {}".format(
self.name, datetime.isoformat(datetime.now())
), f)
self._comment("-" * 40, f) # arguments passed
self._comment("Data: " + args.data, f)
self._comment("Batchsize: {}".format(args.batchsize), f)
self._comment("Test ratio: {}".format(args.test), f)
self._comment("Hard triplet ratio: {}".format(args.skilled), f)
dev = "CPU" if args.gpu < 0 else "GPU ".format(args.gpu)
self._comment("Device: " + dev, f)
if args.initmodel:
self._comment("Init model: " + args.initmodel, f)
if args.resume:
self._comment("Resume state: " + args.resume, f)
self._comment("-" * 40, f) # parameters set in script
self._comment("Optimizer: " + self.optimizer.__class__.__name__, f)
self._comment("Initial LR: {}".format(self.optimizer.lr), f)
self._comment("LR interval: {}".format(args.lrinterval), f)
self._comment("Weight decay: {}".format(args.weight_decay), f)
self._comment("Epoch: {}".format(self.optimizer.epoch), f)
if extra_msg:
self._comment(extra_msg, f)
self._comment("-" * 40, f) # complete call
self._comment("{}".format(sys.argv), f)
self._comment("=" * 40, f)