Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 3 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Showing with 43 additions and 6 deletions.
  1. +15 −0 .activity-partition
  2. +11 −1 activity.py
  3. +6 −4 statistics.py
  4. +11 −1 work_sheet.py
View
15 .activity-partition
@@ -0,0 +1,15 @@
+administration
+animation
+communication
+conseil
+développement logiciel
+divers
+encadrement
+enseignement
+état de l'art
+évaluation
+montage projet
+publication
+recherche
+review article
+review projet
View
12 activity.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# -*- coding: iso-8859-1 -*-
+# -*- coding: utf-8 -*-
#
# Copyright (c) 2010, 2011 CNRS
# Author: Florent Lamiraux
@@ -42,6 +42,10 @@ class Activity (object):
"""
The list of tags this activity is related to
"""
+ partition = set ([])
+ """
+ A set of tags that realizes a partitions of all activities
+ """
startTime = None
"""
Starting time of the activity: a datetime.datetime object
@@ -57,6 +61,12 @@ class Activity (object):
Number of members written in file for each activity
"""
@staticmethod
+ def readPartition (filename):
+ with open (filename, 'r') as f:
+ for line in f:
+ Activity.partition.add (line.strip('\n'))
+
+ @staticmethod
def listToDatetime (strDateAndTime) :
if strDateAndTime == 'None':
return None
View
10 statistics.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# -*- coding: iso-8859-1 -*-
+# -*- coding: utf-8 -*-
#
# Copyright (c) 2010, 2011 CNRS
# Author: Florent Lamiraux
@@ -40,9 +40,11 @@ def displayStatistics(w):
"""
total = w.totalTime
print ("Total time: %f" % total)
- for tag in Activity.tags:
- t = w.extractInter([tag]).totalTime
- print (" %s:\t %f \t%f" % (tag, t, t/total*100) + '%')
+ for p in Activity.partition:
+ t = w.extractUnion([p,]).totalTime
+ line = " " + p + ":" + (30 - len (p))*" " + "\t" + "%.2f"%t +\
+ "\t" + "%.2f"%(t/total*100) + "%"
+ print (line)
if __name__ == '__main__':
w = readFile()
View
12 work_sheet.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# -*- coding: iso-8859-1 -*-
+# -*- coding: utf-8 -*-
#
# Copyright (c) 2010, 2011 CNRS
# Author: Florent Lamiraux
@@ -32,6 +32,7 @@
import datetime as dt
from activity import Activity, TagError
filename = os.getenv('HOME')+"/.activity"
+partition = os.getenv('HOME')+"/.activity-partition"
class CsvDialectComma (csv.Dialect) :
def __init__(self):
@@ -64,6 +65,9 @@ def add(self, activity) :
if not isinstance(activity, Activity) :
raise TypeError("expecting an object of type Activity: got %s"%
repr(activity))
+ if len (activity.instanceTags.intersection (Activity.partition)) != 1:
+ raise RuntimeError ("activity should contain one and only one " +
+ "element of partition.")
self.activities.append(activity)
def write(self, filename) :
@@ -185,6 +189,10 @@ def extractDay(self, year, month, day) :
def extractMonth(self, year, month) :
"""
Extract activities starting a given month
+
+ Input:
+ - year: integer
+ - month: integer between 1 and 12.
"""
init = dt.datetime(year = year, month = month, day=1)
if month < 12:
@@ -208,6 +216,8 @@ def readFile() :
Read $HOME/.activity file and return the correponding work sheet
"""
global filename
+ global partition
+ Activity.readPartition (partition)
w = WorkSheet()
w.read(filename)
return w

No commit comments for this range

Something went wrong with that request. Please try again.