Skip to content

Commit

Permalink
Merge pull request #80 from Navneet78/func/join
Browse files Browse the repository at this point in the history
Func/join
  • Loading branch information
Hrabal committed Oct 8, 2019
2 parents 90f57f0 + d9236be commit 45916fe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tempy/tempy.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,13 @@ def clone(self):
"""Returns a deepcopy of this element."""
return copy(self)

@classmethod
def join(cls, list):
n = len(list)
for index in range(1, 2*n-2, 2):
list.insert(index, cls())
return list


class Escaped(DOMElement):
def __init__(self, content, **kwargs):
Expand Down
6 changes: 6 additions & 0 deletions tests/test_DOMElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,3 +576,9 @@ def test_find(self):

result = tag.find('Br', names='foo') # will return foo -> (Br())
self.assertEqual(len(result), 1)

def test_join(self):
tag= Div()
list=['foo', 'Br', 'Div', 'Pre']
result= tag.join(list)
self.assertEqual(len(result), 7)

0 comments on commit 45916fe

Please sign in to comment.