community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1705202 - /comdev/reporter.apache.org/trunk/mailglomper.py
Date Fri, 25 Sep 2015 00:01:09 GMT
Author: sebb
Date: Fri Sep 25 00:01:09 2015
New Revision: 1705202

URL: http://svn.apache.org/viewvc?rev=1705202&view=rev
Log:
Reduce indent from 8 to 4 spaces (some lines were getting rather long)

Modified:
    comdev/reporter.apache.org/trunk/mailglomper.py

Modified: comdev/reporter.apache.org/trunk/mailglomper.py
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/mailglomper.py?rev=1705202&r1=1705201&r2=1705202&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/mailglomper.py (original)
+++ comdev/reporter.apache.org/trunk/mailglomper.py Fri Sep 25 00:01:09 2015
@@ -5,11 +5,11 @@ from datetime import datetime
 
 mls = {}
 try:
-        with open("data/maildata_extended.json",'r') as f:
-                mls = json.loads(f.read())
-        print("Read JSON")
+    with open("data/maildata_extended.json",'r') as f:
+        mls = json.loads(f.read())
+    print("Read JSON")
 except:
-        pass
+    pass
 
 currentMonth = datetime.now().month
 currentYear = datetime.now().year
@@ -17,14 +17,14 @@ after = time.time() - (86400*92)
 wayafter = time.time() - (86400*92*2)
 months = []
 for i in range(0,7):
-        date = "%04u%02u" % (currentYear, currentMonth)
-        currentMonth -= 1
-        if currentMonth == 0:
-                currentMonth = 12
-                currentYear -= 1
-        months.append(date)
+    date = "%04u%02u" % (currentYear, currentMonth)
+    currentMonth -= 1
+    if currentMonth == 0:
+        currentMonth = 12
+        currentYear -= 1
+    months.append(date)
 
-        now = int(time.time())
+    now = int(time.time())
 
 data = urllib.urlopen("http://mail-archives.us.apache.org/mod_mbox/").read()
 print("Fetched %u bytes of main data" % len(data))
@@ -42,38 +42,36 @@ but this would require converting the in
 the files that process the output for a short while.
 """
 for mlist in re.finditer(r"<a href='([-a-z0-9]+)/'", data):
-        ml = mlist.group(1)
-        y += 1
-        mls[ml] = {}
-        mls[ml]['quarterly'] = [0, 0];
-        mls[ml]['weekly'] = {}
-        for date in months:
+    ml = mlist.group(1)
+    y += 1
+    mls[ml] = {}
+    mls[ml]['quarterly'] = [0, 0];
+    mls[ml]['weekly'] = {}
+    for date in months:
+            
+        try:
+            mldata = urllib.urlopen("http://mail-archives.us.apache.org/mod_mbox/%s/%s.mbox"
% (ml, date)).read()
+            if mldata:
+                for c in re.finditer(r"Date: (.+)", mldata):
+                    try:
+                        d = email.utils.parsedate(c.group(1))
+                        timestamp = int(time.mktime(d))
+                        rounded = timestamp - (timestamp % 604800) + 604800
+                        mls[ml]['weekly'][rounded] = (mls[ml]['weekly'][rounded] if rounded
in mls[ml]['weekly'] else 0) + 1
+                        if timestamp >= after:
+                            mls[ml]['quarterly'][0] += 1
+                        elif timestamp >= wayafter:
+                            mls[ml]['quarterly'][1] += 1
+                    except:
+                        pass
                         
-                try:
-                        mldata = urllib.urlopen("http://mail-archives.us.apache.org/mod_mbox/%s/%s.mbox"
% (ml, date)).read()
-                        if mldata:
-                                for c in re.finditer(r"Date: (.+)", mldata):
-                                        try:
-                                                d = email.utils.parsedate(c.group(1))
-                                                timestamp = int(time.mktime(d))
-                                                rounded = timestamp - (timestamp % 604800)
+ 604800
-                                                mls[ml]['weekly'][rounded] = (mls[ml]['weekly'][rounded]
if rounded in mls[ml]['weekly'] else 0) + 1
-                                                if timestamp >= after:
-                                                        mls[ml]['quarterly'][0] += 1
-                                                elif timestamp >= wayafter:
-                                                        mls[ml]['quarterly'][1] += 1
-                                        except:
-                                                pass
-                                                
-                except Exception as err:
-                        print(err)
-        print("%s: %u" % (ml, mls[ml]['quarterly'][0]))
-        if y == 50:
-                y = 0
-                with open("data/maildata_extended.json",'w+') as f:
-                        f.write(json.dumps(mls, indent=1))
+        except Exception as err:
+            print(err)
+    print("%s: %u" % (ml, mls[ml]['quarterly'][0]))
+    if y == 50:
+        y = 0
+        with open("data/maildata_extended.json",'w+') as f:
+            f.write(json.dumps(mls, indent=1))
 with open("data/maildata_extended.json",'w+') as f:
-        f.write(json.dumps(mls, indent=1))
+    f.write(json.dumps(mls, indent=1))
 print("Dumped JSON")
-
-



Mime
View raw message