- 1
- 2
- 3
- 4
- 5
from db.session import DB
session = DB.session()
session.query(Prefix).filter(Prefix.user_id==user_id, Prefix.prefix.ilike('%your persona:%')).delete()
session.commit()
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
Всего: 6
0
from db.session import DB
session = DB.session()
session.query(Prefix).filter(Prefix.user_id==user_id, Prefix.prefix.ilike('%your persona:%')).delete()
session.commit()
−9
class SimilarCardIsShown(ZenAndroidTest):
def test_similar_show(self):
cards = self.swipe_and_find_elements(By.ID, "com.yandex.zensample.app:id/card_title", 7)
for card in cards:
card.click()
self.driver.back()
assert self.driver.find_element_by_id("com.yandex.zensample.app:id/card_helper_sim_head"), "Нет похожих"
хуй
0
set-executionpolicy unrestricted
set /p name="set name: "
set fullname=%name%.mp4
set /p time="set time: "
set /p path="set path: "
adb shell screenrecord --bit-rate 8000000 --time-limit %time% %fullname%
echo "Recording finished. Pulling %fullname% into current folder:"
adb pull %fullname% %path%
adb shell rm %fullname%
set /p DUMMY="Press Enter to continue"
+1
set-executionpolicy unrestricted
set /p name
set fullname=%name%.mp4
set /p time = "set time"
set /p path = "set path"
adb shell screenrecord --bit-rate 8000000 --time-limit $time $fullname &> $null
echo "Recording finished. Pulling $fullname into current folder:"
adb pull $fullname $path /С/ # $fullname
adb shell rm $fullname
0
import csv
import json
import requests
from io import StringIO
from lxml import etree
class DayPicParser(object):
url = 'урл_до_сайта'
def get_info(self):
handler = open('daypic.csv', 'w+')
page = 1
rows = []
tags = set()
while page <= 1077:
response = requests.get('{}/page/{}'.format(self.url, page))
response.connection.close()
parser = etree.HTMLParser()
tree = etree.parse(StringIO(response.text), parser)
posts = tree.xpath('//div[@class="posts"]/div[@class="post"]')
for i, post in enumerate(posts):
title = post.find('./h2/a')
link_to_fulltext = title.attrib['href']
short_text = post.find('./div[@class="text"]//p[1]')
response = requests.get(link_to_fulltext)
full_parser = etree.HTMLParser()
full_tree = etree.parse(StringIO(response.text), full_parser)
full_post = full_tree.xpath('//div[@class="text"]//p')
main_image = None
full_text = []
for inner in full_post:
if inner.find('.//noindex') is not None:
continue
if inner.find('.//img') is not None:
src = inner.find('.//img').attrib['src']
if not main_image:
main_image = src
full_text.append({'image': src})
for paragraph in etree.tostring(inner, method="text", encoding='utf-8').decode('utf-8').strip().split("\n"):
if paragraph:
full_text.append({'text': paragraph})
rows.append({'title': title.text.strip(),
'preview': main_image if main_image else '',
'short_text': short_text.text.strip(),
'full_text': full_text})
print('Post {} of {}'.format(i, len(posts)))
page += 1
print(page)
handler.write(json.dumps(rows))
handler.close()
print(tags)
DayPicParser().get_info()
−49
import unittest
class TestStringMethods(unittest.TestCase):
def test_upper(self):
self.assertEqual('foo'.upper(), 'FOO')
if __name__ == '__main__':
unittest.main()