[Python-checkins] r83138 - in tracker/instances: meta/detectors/patches.py setuptools/detectors/patches.py

ezio.melotti python-checkins at python.org
Sat Jul 24 17:40:54 CEST 2010


Author: ezio.melotti
Date: Sat Jul 24 17:40:54 2010
New Revision: 83138

Log:
#280: save diff/patch/py attachement to issues in the meta and setuptools trackers as text/plain.

Added:
   tracker/instances/meta/detectors/patches.py
   tracker/instances/setuptools/detectors/patches.py

Added: tracker/instances/meta/detectors/patches.py
==============================================================================
--- (empty file)
+++ tracker/instances/meta/detectors/patches.py	Sat Jul 24 17:40:54 2010
@@ -0,0 +1,17 @@
+# Auditor for patch files
+# Patches should be declared as text/plain (also .py files),
+# independent of what the browser says
+
+import posixpath
+
+sourcetypes = ('.diff', '.patch', '.py')
+
+def ispatch(file, types):
+    return posixpath.splitext(file)[1] in types
+
+def patches_text_plain(db, cl, nodeid, newvalues):
+    if ispatch(newvalues['name'], sourcetypes):
+        newvalues['type'] = 'text/plain'
+
+def init(db):
+    db.file.audit('create', patches_text_plain)

Added: tracker/instances/setuptools/detectors/patches.py
==============================================================================
--- (empty file)
+++ tracker/instances/setuptools/detectors/patches.py	Sat Jul 24 17:40:54 2010
@@ -0,0 +1,17 @@
+# Auditor for patch files
+# Patches should be declared as text/plain (also .py files),
+# independent of what the browser says
+
+import posixpath
+
+sourcetypes = ('.diff', '.patch', '.py')
+
+def ispatch(file, types):
+    return posixpath.splitext(file)[1] in types
+
+def patches_text_plain(db, cl, nodeid, newvalues):
+    if ispatch(newvalues['name'], sourcetypes):
+        newvalues['type'] = 'text/plain'
+
+def init(db):
+    db.file.audit('create', patches_text_plain)


More information about the Python-checkins mailing list