コード例 #1
0
    def test_extend(self):
        u1 = UserList((0, ))
        u2 = UserList((0, 1))
        u = u1[:]
        u.extend(u2)
        self.assertEqual(u, u1 + u2)

        u = UserList("spam")
        u.extend("eggs")
        self.assertEqual(u, list("spameggs"))
コード例 #2
0
 def append(self, *others):
     for other in others:
         if not other:
             continue
         if isinstance(other, Frag) or \
            type(other) == type(()) or \
            type(other) == type([]):
             List.extend(self, other)
         else:
             List.append(self, other)
コード例 #3
0
ファイル: test_userlist.py プロジェクト: sjb8100/UTM-Demo
    def test_extend(self):
        u1 = UserList((0, ))
        u2 = UserList((0, 1))
        u = u1[:]
        u.extend(u2)
        self.assertEqual(u, u1 + u2)

        u = UserList("spam")
        u.extend("eggs")
        self.assertEqual(u, list("spameggs"))
コード例 #4
0
 def append(self, *others):
     for other in others:
         if not other:
             continue
         if isinstance(other, Frag) or \
            type(other) == type(()) or \
            type(other) == type([]):
             List.extend(self, other)
         else:
             List.append(self, other)
コード例 #5
0
ファイル: camera.py プロジェクト: Knio/miru
 def extend(self, lights):
     if self.enforce_limit:
         _constrain_lights(len(self) + len(lights))
     lts = []
     for i, l in enumerate(lights):
         if self.enforce_limit:
             l.light_no = lightno(len(self) + i)
         else:
             l.light_no = vlightno(len(self) + i)
         lts.append(l)
     UserList.extend(self, lts)
コード例 #6
0
ファイル: test_iterlen.py プロジェクト: circinusX1/minimarmfs
 def test_mutation(self):
     d = UserList(range(n))
     it = reversed(d)
     it.next()
     it.next()
     self.assertEqual(len(it), n - 2)
     d.append(n)
     self.assertEqual(len(it), n - 2)  # ignore append
     d[1:] = []
     self.assertEqual(len(it), 0)
     self.assertEqual(list(it), [])  # confirm invariant
     d.extend(xrange(20))
     self.assertEqual(len(it), 0)
コード例 #7
0
ファイル: test_iterlen.py プロジェクト: Alex-CS/sonify
 def test_mutation(self):
     d = UserList(range(n))
     it = iter(d)
     it.next()
     it.next()
     self.assertEqual(len(it), n-2)
     d.append(n)
     self.assertEqual(len(it), n-1)  # grow with append
     d[1:] = []
     self.assertEqual(len(it), 0)
     self.assertEqual(list(it), [])
     d.extend(xrange(20))
     self.assertEqual(len(it), 0)
コード例 #8
0
ファイル: test_iterlen.py プロジェクト: Alex-CS/sonify
 def test_mutation(self):
     d = UserList(range(n))
     it = reversed(d)
     it.next()
     it.next()
     self.assertEqual(len(it), n-2)
     d.append(n)
     self.assertEqual(len(it), n-2)  # ignore append
     d[1:] = []
     self.assertEqual(len(it), 0)
     self.assertEqual(list(it), [])  # confirm invariant
     d.extend(xrange(20))
     self.assertEqual(len(it), 0)
コード例 #9
0
ファイル: test_iterlen.py プロジェクト: circinusX1/minimarmfs
 def test_mutation(self):
     d = UserList(range(n))
     it = iter(d)
     it.next()
     it.next()
     self.assertEqual(len(it), n - 2)
     d.append(n)
     self.assertEqual(len(it), n - 1)  # grow with append
     d[1:] = []
     self.assertEqual(len(it), 0)
     self.assertEqual(list(it), [])
     d.extend(xrange(20))
     self.assertEqual(len(it), 0)
コード例 #10
0
ファイル: test_iterobject.py プロジェクト: TheDunn/flex-pypy
 def test_mutation_seqiter_reversed(self):
     from UserList import UserList
     n = 5
     d = UserList(range(n))
     it = reversed(d)
     it.next()
     it.next()
     assert len(it) == n-2
     d.append(n)
     assert len(it) == n-2  # ignore append
     d[1:] = []
     assert len(it) == 0
     assert list(it) == []
     d.extend(xrange(20))
     assert len(it) == 0
コード例 #11
0
ファイル: test_iterobject.py プロジェクト: TheDunn/flex-pypy
 def test_mutation_seqiter(self):
     from UserList import UserList
     n = 5
     d = UserList(range(n))
     it = iter(d)
     it.next()
     it.next()
     assert len(it) == n-2
     d.append(n)
     assert len(it) == n-1  # grow with append
     d[1:] = []
     assert len(it) == 0
     assert list(it) == []
     d.extend(xrange(20))
     assert len(it) == 0
コード例 #12
0
ファイル: test_iterobject.py プロジェクト: griels/pypy-sc
 def test_mutation_seqiter_reversed(self):
     from UserList import UserList
     n = 5
     d = UserList(range(n))
     it = reversed(d)
     it.next()
     it.next()
     assert len(it) == n-2
     d.append(n)
     assert len(it) == n-2  # ignore append
     d[1:] = []
     assert len(it) == 0
     assert list(it) == []
     d.extend(xrange(20))
     assert len(it) == 0
コード例 #13
0
ファイル: test_iterobject.py プロジェクト: griels/pypy-sc
 def test_mutation_seqiter(self):
     from UserList import UserList
     n = 5
     d = UserList(range(n))
     it = iter(d)
     it.next()
     it.next()
     assert len(it) == n-2
     d.append(n)
     assert len(it) == n-1  # grow with append
     d[1:] = []
     assert len(it) == 0
     assert list(it) == []
     d.extend(xrange(20))
     assert len(it) == 0
コード例 #14
0
ファイル: diskdoc.py プロジェクト: dotmpe/script-mpe
def get_local_parts(ctx, *attr):
    "Get a list of available/mounted local partitions"
    parts = UserList()

    # Get a list of objects depending on host OS
    if ctx.uname == 'Darwin':
        parts.extend( readout_attr(*readout_attr_presets['darwin_lib_mounts']) )

    elif ctx.uname == 'Linux':
        parts.extend( [ p for p in
                    readout_attr( *readout_attr_presets['linux_mounts'] )
                if os.path.exists(p.device) ] )

    else:
        raise Exception("Unknown OS '{0}'".format(ctx.uname))

    # Fill in missing attributes, if requested explicitly
    return fetch_parts_attr(parts, ctx, *attr)
コード例 #15
0
    def simple_search(self, query, max_length=MAX_RESULT_LENGTH, **kwargs):
        """
        Smart searchs query in books (in title and authors).
        Supports args: query, tag, lang, max_length.
        """
        query_ex = dict(kwargs)
        query_ex['title'] = query
        query_ex['author'] = query

        # search in title and in author
        books = UserList(self.__book_search(max_length, **query_ex))

        if len(books) < max_length:
            # search only in title
            del query_ex['author']
            books_a = self.__book_search(max_length, **query_ex)

            books_id_set = set([b.id for b in books])
            # merge results
            added_book_num = len(books)
            for book in books_a:
                if not book.id in books_id_set:
                    books.append(book)
                    added_book_num += 1
                    if added_book_num == max_length:
                        break

        del query_ex['title']
        if len(books) < MIN_LEN_RESULT:
            query_ex['author'] = query
            authors = UserList(self.__author_search(1, **query_ex))
            if authors:
                # TODO add filtering by language and tag here
                authors_books = authors[0].book_set.all()
                books.extend(authors_books)
            del query_ex['author']

        query_ex['query'] = query
        books.suggestion = self.__get_suggetions(**query_ex)
        return books
コード例 #16
0
 def extend(self, alist):
     for x in alist:
         self.__register_field(x)
     list.extend(self, alist)
コード例 #17
0
 def extend(self, other):
     for obj in other:
         validateInformation(obj)
     UserList.extend(self, other)
コード例 #18
0
ファイル: importLib.py プロジェクト: jdobes/spacewalk
 def extend(self, other):
     for obj in other:
         validateInformation(obj)
     UserList.extend(self, other)
コード例 #19
0
ファイル: TypedList.py プロジェクト: djhenderson/EaseXML3
 def extend(self, other):
     other2 = self.checkList(other)
     UserList.extend(self, other2)
コード例 #20
0
ファイル: Models.py プロジェクト: hiddenman/impexp
 def extend(self, other):
     UserList.extend(self, other)
     self.notify()
コード例 #21
0
# Test index

check(u2.index(0) == 0, "u2.index(0) == 0")
check(u2.index(1) == 1, "u2.index(1) == 1")
try:
    u2.index(2)
except ValueError:
    pass
else:
    raise TestFailed("expected ValueError")

# Test reverse

u = u2[:]
u.reverse()
check(u == [1, 0], "u == [1, 0]")
u.reverse()
check(u == u2, "u == u2")

# Test sort

u = UserList([1, 0])
u.sort()
check(u == u2, "u == u2")

# Test extend

u = u1[:]
u.extend(u2)
check(u == u1 + u2, "u == u1 + u2")
コード例 #22
0
ファイル: base.py プロジェクト: dainmiller/vimwiki-org
 def extend(self, other):
     UserList.extend(self, other)
     self._changed()
コード例 #23
0
ファイル: test_userlist.py プロジェクト: arandilopez/z-eves
assert u2.index(0) == 0
assert u2.index(1) == 1
try:
    u2.index(2)
except ValueError:
    pass
else:
    assert 0, "expected ValueError"

# Test reverse

u = u2[:]
u.reverse()
assert u == [1, 0]
u.reverse()
assert u == u2

# Test sort

u = UserList([1, 0])
u.sort()
assert u == u2

# Test extend

u = u1[:]
u.extend(u2)
assert u == u1 + u2

コード例 #24
0
ファイル: Util.py プロジェクト: bluebellzhy/chromium
 def extend(self, other):
     UserList.extend(self, other)
     self.unique = False
コード例 #25
0
ファイル: liborgmode.py プロジェクト: Sophrinix/vim-orgmode
	def extend(self, other):
		UserList.extend(self, other)
		self._changed()
コード例 #26
0
ファイル: orbitals.py プロジェクト: jkn93/orbkit
 def extend(self, item):
     UserList.extend(self, item)
     self._up_to_date = False
コード例 #27
0
ファイル: Util.py プロジェクト: georgescubogdan/PP
 def extend(self, other):
     UserList.extend(self, other)
     self.unique = False
コード例 #28
0
 def extend(self, alist):
     for x in alist:
         self.__register_field(x)
     list.extend(self, alist)
コード例 #29
0
ファイル: test_userlist.py プロジェクト: mcyril/ravel-ftn
# Check every path through every method of UserList
from UserList import UserList
from test_support import TestFailed
# Use check instead of assert so -O doesn't render the
# test useless.
# XXX: could use the verify function in test_support instead
def check(predicate, msg):
    if not predicate:
        raise TestFailed(msg + " failed")
l0 = []
l1 = [0]
l2 = [0, 1]
# Test constructors
u = UserList()
u0 = UserList(l0)
u1 = UserList(l1)
u2 = UserList(l2)
uu = UserList(u)
uu0 = UserList(u0)
uu1 = UserList(u1)
uu2 = UserList(u2)
v = UserList(tuple(u))
class OtherList:
    def __init__(self, initlist):
        self.__data = initlist
    def __len__(self):
        return len(self.__data)
    def __getitem__(self, i):
        return self.__data[i]
v0 = UserList(OtherList(u0))