コード例 #1
0
ファイル: reports.py プロジェクト: IPZS/hamster
    def _write_fact(self, fact):
        # no having end time is fine
        end_time_str, end_time_iso_str = "", ""
        if fact.end_time:
            end_time_str = fact.end_time.strftime('%H:%M')
            end_time_iso_str = fact.end_time.isoformat()

        category = ""
        if fact.category != _("Unsorted"): #do not print "unsorted" in list
            category = fact.category


        data = dict(
            date = fact.date.strftime(
                   # date column format for each row in HTML report
                   # Using python datetime formatting syntax. See:
                   # http://docs.python.org/library/time.html#time.strftime
                   C_("html report","%b %d, %Y")),
            date_iso = fact.date.isoformat(),
            activity = fact.activity,
            category = category,
            tags = fact.tags,
            start = fact.start_time.strftime('%H:%M'),
            start_iso = fact.start_time.isoformat(),
            end = end_time_str,
            end_iso = end_time_iso_str,
            duration = stuff.format_duration(fact.delta) or "",
            duration_minutes = "%d" % (stuff.duration_minutes(fact.delta)),
            duration_decimal = "%.2f" % (stuff.duration_minutes(fact.delta) / 60.0),
            description = fact.description or ""
        )
        self.fact_rows.append(Template(self.fact_row_template).safe_substitute(data))
コード例 #2
0
    def _write_fact(self, fact):
        # no having end time is fine
        end_time_str, end_time_iso_str = "", ""
        if fact.end_time:
            end_time_str = fact.end_time.strftime('%H:%M')
            end_time_iso_str = fact.end_time.isoformat()

        category = ""
        if fact.category != _("Unsorted"):  #do not print "unsorted" in list
            category = fact.category

        data = dict(
            date=fact.date.strftime(
                # date column format for each row in HTML report
                # Using python datetime formatting syntax. See:
                # http://docs.python.org/library/time.html#time.strftime
                C_("html report", "%b %d, %Y")),
            date_iso=fact.date.isoformat(),
            activity=fact.activity,
            category=category,
            tags=", ".join(fact.tags),
            start=fact.start_time.strftime('%H:%M'),
            start_iso=fact.start_time.isoformat(),
            end=end_time_str,
            end_iso=end_time_iso_str,
            duration=stuff.format_duration(fact.delta) or "",
            duration_minutes="%d" % (stuff.duration_minutes(fact.delta)),
            duration_decimal="%.2f" %
            (stuff.duration_minutes(fact.delta) / 60.0),
            description=fact.description or "")
        self.fact_rows.append(
            Template(self.fact_row_template).safe_substitute(data))
コード例 #3
0
ファイル: trophies.py プロジェクト: webnard/hamster
def check_ongoing(todays_facts):
    if not storage or not todays_facts: return

    last_activity = None
    if todays_facts[-1].end_time is None:
        last_activity = todays_facts[-1]
        last_activity.delta = dt.datetime.now() - last_activity.start_time

    # overwhelmed: tracking for more than 16 hours during one day
    total = stuff.duration_minutes([fact.delta for fact in todays_facts])
    if total > 16 * 60:
        unlock("overwhelmed")

    if last_activity:
        # Welcome! – track an activity for 10 minutes
        if last_activity.delta >= dt.timedelta(minutes=10):
            unlock("welcome")

        # in_the_zone - spend 6 hours non-stop on an activity
        if last_activity.delta >= dt.timedelta(hours=6):
            unlock("in_the_zone")

        # insomnia - meet the new day while tracking an activity
        if last_activity.start_time.date() != dt.date.today():
            unlock("insomnia")
コード例 #4
0
ファイル: reports.py プロジェクト: webnard/hamster
 def _write_fact(self, fact):
     self.csv_writer.writerow([fact.activity,
                               fact.start_time,
                               fact.end_time,
                               str(stuff.duration_minutes(fact.delta)),
                               fact.category,
                               fact.description,
                               ", ".join(fact.tags)])
コード例 #5
0
ファイル: reports.py プロジェクト: IPZS/hamster
 def _write_fact(self, fact):
     fact.delta = stuff.duration_minutes(fact.delta)
     self.csv_writer.writerow([fact.activity,
                               fact.start_time,
                               fact.end_time,
                               fact.delta,
                               fact.category,
                               fact.description,
                               fact.tags])
コード例 #6
0
ファイル: reports.py プロジェクト: webnard/hamster
 def _write_fact(self, fact):
     activity = self.doc.createElement("activity")
     activity.setAttribute("name", fact.activity)
     activity.setAttribute("start_time", str(fact.start_time))
     activity.setAttribute("end_time", str(fact.end_time))
     activity.setAttribute("duration_minutes", str(stuff.duration_minutes(fact.delta)))
     activity.setAttribute("category", fact.category)
     activity.setAttribute("description", fact.description)
     activity.setAttribute("tags", ", ".join(fact.tags))
     self.activity_list.appendChild(activity)
コード例 #7
0
ファイル: reports.py プロジェクト: IPZS/hamster
 def _write_fact(self, fact):
     activity = self.doc.createElement("activity")
     activity.setAttribute("name", fact.activity)
     activity.setAttribute("start_time", fact.start_time)
     activity.setAttribute("end_time", fact.end_time)
     activity.setAttribute("duration_minutes", str(stuff.duration_minutes(fact.delta)))
     activity.setAttribute("category", fact.category)
     activity.setAttribute("description", fact.description)
     activity.setAttribute("tags", fact.tags)
     self.activity_list.appendChild(activity)
コード例 #8
0
ファイル: reports.py プロジェクト: axmachado/hamster
 def _write_fact(self, fact):
     fact.delta = stuff.duration_minutes(fact.delta)
     factData = [fact.activity,
                 fact.start_time,
                 fact.end_time,
                 fact.delta,
                 fact.category,
                 fact.description,
                 u", ".join(fact.tags)]
     self.csv_writer.writerow([ unicode(field).encode(self.outputEncoding) for field in factData ])
コード例 #9
0
ファイル: reports.py プロジェクト: tszymanski/hamster
 def _write_fact(self, fact):
     fact.delta = stuff.duration_minutes(fact.delta)
     self.csv_writer.writerow([
         fact.activity, fact.start_time, fact.end_time, fact.delta,
         fact.category, fact.description, fact.tags
     ])