[27557] in Source-Commits
pyhesiodfs commit: Drop support for Python < 2.6
daemon@ATHENA.MIT.EDU (Jonathan D Reed)
Tue Dec 31 12:27:31 2013
Date: Tue, 31 Dec 2013 12:27:23 -0500
From: Jonathan D Reed <jdreed@MIT.EDU>
Message-Id: <201312311727.rBVHRNO5027078@drugstore.mit.edu>
To: source-commits@MIT.EDU
https://github.com/mit-athena/pyhesiodfs/commit/723a2f07507d78a03d49b8984cc91c597c447f3d
commit 723a2f07507d78a03d49b8984cc91c597c447f3d
Author: Jonathan Reed <jdreed@mit.edu>
Date: Thu Nov 14 14:44:09 2013 -0500
Drop support for Python < 2.6
We want to require 2.6, because we're using Python 2.6 syntax in
exceptions. This also means we can drop our own implementation of
defaultdict, since collections.defaultdict has been around since
Python 2.5.
pyHesiodFS.py | 33 +++++++--------------------------
1 files changed, 7 insertions(+), 26 deletions(-)
diff --git a/pyHesiodFS.py b/pyHesiodFS.py
index b4f1e59..d9ed131 100644
--- a/pyHesiodFS.py
+++ b/pyHesiodFS.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.5
+#!/usr/bin/python2
# pyHesiodFS:
# Copyright (C) 2007 Quentin Smith <quentin@mit.edu>
@@ -9,37 +9,18 @@
# See the file COPYING.
#
-import sys, os, stat, errno, time
+import sys
+if sys.hexversion < 0x020600f0:
+ sys.exit("Python 2.6 or higher is required.")
+
+import os, stat, errno, time
from syslog import *
import fuse
from fuse import Fuse
+from collections import defaultdict
import hesiod
-try:
- from collections import defaultdict
-except ImportError:
- class defaultdict(dict):
- """
- A dictionary that automatically will fill in keys that don't exist
- with the result from some default value factory
-
- Based on the collections.defaultdict object in Python 2.5
- """
-
- def __init__(self, default_factory):
- self.default_factory = default_factory
- super(defaultdict, self).__init__()
-
- def __getitem__(self, y):
- if y not in self:
- self[y] = self.default_factory()
- return super(defaultdict, self).__getitem__(y)
-
- def __str__(self):
- return 'defaultdict(%s, %s)' % (self.default_factory,
- super(defaultdict, self).__str__())
-
class negcache(dict):
"""
A set-like object that automatically expunges entries after