我们从Python开源项目中,提取了以下21个代码示例,用于说明如何使用audioop.reverse()。
def make_html_content_and_add_tags(self): # ????? ???? ????? p = re.compile(r'(#\w+)') # findall???? ???? ????? ??? tag_name_list = re.findall(p, self.content) # ?? content(Comment??)? ??? ?? ori_content = self.content # ????? ???? for tag_name in tag_name_list: # Tag??? ????? ??, ????? ???? ????? _?? tag, _ = Tag.objects.get_or_create(name=tag_name.replace('#', '')) # ?? content? ??? ?? change_tag = '<a href="{url}" class="hash-tag">{tag_name}</a>'.format( # url=reverse('post:hashtag_post_list', args=[tag_name.replace('#', '')]), url=reverse('post:hashtag_post_list', kwargs={'tag_name': tag_name.replace('#', '')}), tag_name=tag_name ) ori_content = re.sub(r'{}(?![<\w])'.format(tag_name), change_tag, ori_content, count=1) # content? ??? Tag??? ??? tags??? ?? if not self.tags.filter(pk=tag.pk).exists(): self.tags.add(tag) # ??? ??? ???? html_content? ?? self.html_content = ori_content super().save(update_fields=['html_content'])
def test_issue7673(self): state = None for data, size in INVALID_DATA: size2 = size self.assertRaises(audioop.error, audioop.getsample, data, size, 0) self.assertRaises(audioop.error, audioop.max, data, size) self.assertRaises(audioop.error, audioop.minmax, data, size) self.assertRaises(audioop.error, audioop.avg, data, size) self.assertRaises(audioop.error, audioop.rms, data, size) self.assertRaises(audioop.error, audioop.avgpp, data, size) self.assertRaises(audioop.error, audioop.maxpp, data, size) self.assertRaises(audioop.error, audioop.cross, data, size) self.assertRaises(audioop.error, audioop.mul, data, size, 1.0) self.assertRaises(audioop.error, audioop.tomono, data, size, 0.5, 0.5) self.assertRaises(audioop.error, audioop.tostereo, data, size, 0.5, 0.5) self.assertRaises(audioop.error, audioop.add, data, data, size) self.assertRaises(audioop.error, audioop.bias, data, size, 0) self.assertRaises(audioop.error, audioop.reverse, data, size) self.assertRaises(audioop.error, audioop.lin2lin, data, size, size2) self.assertRaises(audioop.error, audioop.ratecv, data, size, 1, 1, 1, state) self.assertRaises(audioop.error, audioop.lin2ulaw, data, size) self.assertRaises(audioop.error, audioop.lin2alaw, data, size) self.assertRaises(audioop.error, audioop.lin2adpcm, data, size, state)
def test_string(self): data = 'abcd' size = 2 self.assertRaises(TypeError, audioop.getsample, data, size, 0) self.assertRaises(TypeError, audioop.max, data, size) self.assertRaises(TypeError, audioop.minmax, data, size) self.assertRaises(TypeError, audioop.avg, data, size) self.assertRaises(TypeError, audioop.rms, data, size) self.assertRaises(TypeError, audioop.avgpp, data, size) self.assertRaises(TypeError, audioop.maxpp, data, size) self.assertRaises(TypeError, audioop.cross, data, size) self.assertRaises(TypeError, audioop.mul, data, size, 1.0) self.assertRaises(TypeError, audioop.tomono, data, size, 0.5, 0.5) self.assertRaises(TypeError, audioop.tostereo, data, size, 0.5, 0.5) self.assertRaises(TypeError, audioop.add, data, data, size) self.assertRaises(TypeError, audioop.bias, data, size, 0) self.assertRaises(TypeError, audioop.reverse, data, size) self.assertRaises(TypeError, audioop.lin2lin, data, size, size) self.assertRaises(TypeError, audioop.ratecv, data, size, 1, 1, 1, None) self.assertRaises(TypeError, audioop.lin2ulaw, data, size) self.assertRaises(TypeError, audioop.lin2alaw, data, size) self.assertRaises(TypeError, audioop.lin2adpcm, data, size, None)
def test_reverse(self): self.assertEqual(audioop.reverse(data[0], 1), b'\2\1\0')
def vote(request, question_id): question = get_object_or_404(Question,pk = question_id) try: selected_choice = question.choice_set.get(pk = request.POST['choice']) except (KeyError, Choice.DoesNotExists): return render(request, 'polls/detail.html',{ 'question': question, 'error_message' : "You didn't select a choice.", }) else: selected_choice.votes += 1 selected_choice.save() return HttpResponseRedirect(reverse('polls:results', args = (question.id))) #return HttpResponse("You're voting on question %s." % question_id)
def test_reverse(self): for w in 1, 2, 4: self.assertEqual(audioop.reverse(b'', w), b'') self.assertEqual(audioop.reverse(packs[w](0, 1, 2), w), packs[w](2, 1, 0))
def test_reverse(self): for w in 1, 2, 3, 4: self.assertEqual(audioop.reverse(b'', w), b'') self.assertEqual(audioop.reverse(bytearray(), w), b'') self.assertEqual(audioop.reverse(memoryview(b''), w), b'') self.assertEqual(audioop.reverse(packs[w](0, 1, 2), w), packs[w](2, 1, 0))
def reverse(self): """Reverse the sound.""" assert not self.__locked self.__frames = audioop.reverse(self.__frames, self.__samplewidth) return self