Merge lp:~mterry/duplicity/drop-static into lp:duplicity/0.6

Proposed by Michael Terry
Status: Merged
Merged at revision: 976
Proposed branch: lp:~mterry/duplicity/drop-static
Merge into: lp:duplicity/0.6
Diff against target: 268 lines (+13/-137)
4 files modified
duplicity/lazy.py (+13/-4)
duplicity/static.py (+0/-46)
po/POTFILES.in (+0/-1)
testing/tests/test_static.py (+0/-86)
To merge this branch: bzr merge lp:~mterry/duplicity/drop-static
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+216456@code.launchpad.net

Description of the change

Drop static.py.

This is some of the oldest code in duplicity! A bzr blame says it is unmodified (except for whitespace / comment changes) since revision 1.

But it's not needed anymore. Not really even since we updated to python2.4, which introduced the @staticmethod decorator. So this branch drops it and its test file.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'duplicity/lazy.py'
2--- duplicity/lazy.py 2013-12-27 06:39:00 +0000
3+++ duplicity/lazy.py 2014-04-18 14:36:20 +0000
4@@ -23,46 +23,51 @@
5
6 import os
7
8-from duplicity.static import * #@UnusedWildImport
9-
10
11 class Iter:
12 """Hold static methods for the manipulation of lazy iterators"""
13
14+ @staticmethod
15 def filter(predicate, iterator): #@NoSelf
16 """Like filter in a lazy functional programming language"""
17 for i in iterator:
18 if predicate(i):
19 yield i
20
21+ @staticmethod
22 def map(function, iterator): #@NoSelf
23 """Like map in a lazy functional programming language"""
24 for i in iterator:
25 yield function(i)
26
27+ @staticmethod
28 def foreach(function, iterator): #@NoSelf
29 """Run function on each element in iterator"""
30 for i in iterator:
31 function(i)
32
33+ @staticmethod
34 def cat(*iters): #@NoSelf
35 """Lazily concatenate iterators"""
36 for iter in iters:
37 for i in iter:
38 yield i
39
40+ @staticmethod
41 def cat2(iter_of_iters): #@NoSelf
42 """Lazily concatenate iterators, iterated by big iterator"""
43 for iter in iter_of_iters:
44 for i in iter:
45 yield i
46
47+ @staticmethod
48 def empty(iter): #@NoSelf
49 """True if iterator has length 0"""
50 for i in iter: #@UnusedVariable
51 return None
52 return 1
53
54+ @staticmethod
55 def equal(iter1, iter2, verbose = None, operator = lambda x, y: x == y): #@NoSelf
56 """True if iterator 1 has same elements as iterator 2
57
58@@ -88,6 +93,7 @@
59 print "End when i2 = %s" % (i2,)
60 return None
61
62+ @staticmethod
63 def Or(iter): #@NoSelf
64 """True if any element in iterator is true. Short circuiting"""
65 i = None
66@@ -96,6 +102,7 @@
67 return i
68 return i
69
70+ @staticmethod
71 def And(iter): #@NoSelf
72 """True if all elements in iterator are true. Short circuiting"""
73 i = 1
74@@ -104,6 +111,7 @@
75 return i
76 return i
77
78+ @staticmethod
79 def len(iter): #@NoSelf
80 """Return length of iterator"""
81 i = 0
82@@ -114,6 +122,7 @@
83 return i
84 i = i+1
85
86+ @staticmethod
87 def foldr(f, default, iter): #@NoSelf
88 """foldr the "fundamental list recursion operator"?"""
89 try:
90@@ -122,6 +131,7 @@
91 return default
92 return f(next, Iter.foldr(f, default, iter))
93
94+ @staticmethod
95 def foldl(f, default, iter): #@NoSelf
96 """the fundamental list iteration operator.."""
97 while 1:
98@@ -131,6 +141,7 @@
99 return default
100 default = f(default, next)
101
102+ @staticmethod
103 def multiplex(iter, num_of_forks, final_func = None, closing_func = None): #@NoSelf
104 """Split a single iterater into a number of streams
105
106@@ -191,8 +202,6 @@
107
108 return tuple(map(make_iterator, range(num_of_forks)))
109
110-MakeStatic(Iter)
111-
112
113 class IterMultiplex2:
114 """Multiplex an iterator into 2 parts
115
116=== removed file 'duplicity/static.py'
117--- duplicity/static.py 2009-04-01 15:07:45 +0000
118+++ duplicity/static.py 1970-01-01 00:00:00 +0000
119@@ -1,46 +0,0 @@
120-# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
121-#
122-# Copyright 2002 Ben Escoto <ben@emerose.org>
123-# Copyright 2007 Kenneth Loafman <kenneth@loafman.com>
124-#
125-# This file is part of duplicity.
126-#
127-# Duplicity is free software; you can redistribute it and/or modify it
128-# under the terms of the GNU General Public License as published by the
129-# Free Software Foundation; either version 2 of the License, or (at your
130-# option) any later version.
131-#
132-# Duplicity is distributed in the hope that it will be useful, but
133-# WITHOUT ANY WARRANTY; without even the implied warranty of
134-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
135-# General Public License for more details.
136-#
137-# You should have received a copy of the GNU General Public License
138-# along with duplicity; if not, write to the Free Software Foundation,
139-# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
140-
141-"""MakeStatic and MakeClass
142-
143-These functions are used to make all the instance methods in a class
144-into static or class methods.
145-
146-"""
147-
148-class StaticMethodsError(Exception): pass
149-
150-def MakeStatic(cls):
151- """turn instance methods into static ones
152-
153- The methods (that don't begin with _) of any class that
154- subclasses this will be turned into static methods.
155-
156- """
157- for name in dir(cls):
158- if name[0] != "_":
159- cls.__dict__[name] = staticmethod(cls.__dict__[name])
160-
161-def MakeClass(cls):
162- """Turn instance methods into classmethods. Ignore _ like above"""
163- for name in dir(cls):
164- if name[0] != "_":
165- cls.__dict__[name] = classmethod(cls.__dict__[name])
166
167=== modified file 'po/POTFILES.in'
168--- po/POTFILES.in 2014-04-17 19:34:23 +0000
169+++ po/POTFILES.in 2014-04-18 14:36:20 +0000
170@@ -16,7 +16,6 @@
171 duplicity/log.py
172 duplicity/robust.py
173 duplicity/misc.py
174-duplicity/static.py
175 duplicity/diffdir.py
176 duplicity/lazy.py
177 duplicity/backends/_cf_pyrax.py
178
179=== removed file 'testing/tests/test_static.py'
180--- testing/tests/test_static.py 2014-04-16 02:43:43 +0000
181+++ testing/tests/test_static.py 1970-01-01 00:00:00 +0000
182@@ -1,86 +0,0 @@
183-# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
184-#
185-# Copyright 2002 Ben Escoto <ben@emerose.org>
186-# Copyright 2007 Kenneth Loafman <kenneth@loafman.com>
187-#
188-# This file is part of duplicity.
189-#
190-# Duplicity is free software; you can redistribute it and/or modify it
191-# under the terms of the GNU General Public License as published by the
192-# Free Software Foundation; either version 2 of the License, or (at your
193-# option) any later version.
194-#
195-# Duplicity is distributed in the hope that it will be useful, but
196-# WITHOUT ANY WARRANTY; without even the implied warranty of
197-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
198-# General Public License for more details.
199-#
200-# You should have received a copy of the GNU General Public License
201-# along with duplicity; if not, write to the Free Software Foundation,
202-# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
203-
204-import helper
205-import unittest, types, sys
206-
207-from duplicity.static import * #@UnusedWildImport
208-
209-helper.setup()
210-
211-class D:
212- def foo(x, y): #@NoSelf
213- return x, y
214- def bar(self, x):
215- return 3, x
216- def _hello(self):
217- return self
218-
219-MakeStatic(D)
220-
221-
222-class C:
223- _a = 0
224- def get(cls): #@NoSelf
225- return cls._a
226- def inc(cls): #@NoSelf
227- cls._a = cls._a + 1
228-
229-MakeClass(C)
230-
231-
232-class StaticMethodsTest(unittest.TestCase):
233- """Test StaticMethods module"""
234- def testType(self):
235- """Methods should have type StaticMethod"""
236- assert type(D.foo) is types.FunctionType
237- assert type(D.bar) is types.FunctionType
238-
239- def testStatic(self):
240- """Methods should be callable without instance"""
241- assert D.foo(1,2) == (1,2)
242- assert D.bar(3,4) == (3,4)
243-
244- def testBound(self):
245- """Methods should also work bound"""
246- d = D()
247- assert d.foo(1,2) == (1,2)
248- assert d.bar(3,4) == (3,4)
249-
250- def testStatic_(self):
251- """_ Methods should be untouched"""
252- d = D()
253- self.assertRaises(TypeError, d._hello, 4)
254- assert d._hello() is d
255-
256-
257-class ClassMethodsTest(unittest.TestCase):
258- def test(self):
259- """Test MakeClass function"""
260- assert C.get() == 0
261- C.inc()
262- assert C.get() == 1
263- C.inc()
264- assert C.get() == 2
265-
266-
267-if __name__ == "__main__":
268- unittest.main()

Subscribers

People subscribed via source and target branches

to all changes: