incubator-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r1545528 - /incubator/public/trunk/report_timeline.py
Date Tue, 26 Nov 2013 03:17:33 GMT
Author: marvin
Date: Tue Nov 26 03:17:32 2013
New Revision: 1545528

URL: http://svn.apache.org/r1545528
Log:
Add script/class representing report timeline.

The `Timeline` class represents the events associated with preparing an
Incubator board report.  The script on may be run on its own to output
plain text suitable for email, or may be used as a module in order to
create a MoinMoin table suitable for our wiki report template.

Added:
    incubator/public/trunk/report_timeline.py   (with props)

Added: incubator/public/trunk/report_timeline.py
URL: http://svn.apache.org/viewvc/incubator/public/trunk/report_timeline.py?rev=1545528&view=auto
==============================================================================
--- incubator/public/trunk/report_timeline.py (added)
+++ incubator/public/trunk/report_timeline.py Tue Nov 26 03:17:32 2013
@@ -0,0 +1,91 @@
+#!/usr/bin/env python3
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import datetime
+import sys
+import argparse
+
+class Timeline(object):
+    """Timeline of events associated with an Incubator Board report."""
+
+    def __init__(self, month):
+        self._month = month
+        now = datetime.datetime.now()
+        self._year = now.year if month >= now.month else now.year + 1
+        for day in range(1, 7):
+            first_wed = datetime.date(day=day, month=self._month,
+                                      year=self._year)
+            if first_wed.weekday() == 2:
+                break
+        self._events = []
+        self._date = first_wed.replace(day=first_wed.day + 14)
+        self._add_event(desc="Podling reports due by end of day",
+                        date=first_wed)
+        self._add_event(desc="Shepherd reviews due by end of day",
+                        date=first_wed.replace(day=first_wed.day + 4))
+        self._add_event(desc="Summary due by end of day",
+                        date=first_wed.replace(day=first_wed.day + 4))
+        self._add_event(desc="Mentor signoff due by end of day",
+                        date=first_wed.replace(day=first_wed.day + 6))
+        self._add_event(desc="Report submitted to Board",
+                        date=first_wed.replace(day=first_wed.day + 7))
+        self._add_event(desc="Board meeting",
+                        date=first_wed.replace(day=first_wed.day + 14))
+
+    def _add_event(self, desc, date):
+        self._events.append({"desc": desc, "date": date})
+
+    def to_moin(self):
+        """Represent the timeline as a table in MoinMoin wiki syntax."""
+        moin = ""
+        for event in self._events:
+            moin += '||{0:%a} {0:%B} {0:%d} ||{1} ||\n'.format(event['date'],
+                                                               event['desc'])
+        return moin
+
+    def to_email(self):
+        """Represent the timeline as plain text email content."""
+        template = """
+            {date:%B} {date:%Y} Incubator report timeline:
+
+                http://wiki.apache.org/incubator/{date:%B}{date:%Y}
+
+            """.replace("\n            ", "\n")
+        text = template.format(date=self._date)
+        for event in self._events:
+            text += '    {0:%a} {0:%B} {0:%d} -- {1}\n'.format(event['date'],
+                                                               event['desc'])
+        return text
+
+def process_cli_args():
+    parser = argparse.ArgumentParser()
+    parser.add_argument('--month', type=int, default=0,
+                        help="month number (1-12)")
+    options = parser.parse_args()
+    if options.month == 0:
+        now = datetime.datetime.now()
+        options.month = (now.month % 12) + 1
+    return options
+
+def main():
+    options = process_cli_args()
+    timeline = Timeline(month=options.month)
+    print(timeline.to_email())
+
+if __name__ == '__main__':
+    main()
+

Propchange: incubator/public/trunk/report_timeline.py
------------------------------------------------------------------------------
    svn:executable = *



---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@incubator.apache.org
For additional commands, e-mail: cvs-help@incubator.apache.org


Mime
View raw message