Пример #1
0
def test_cut_list_of_tuple():
    assert cut(list_of_tuple)[3] == [3, 0, 21]
    assert cut(list_of_tuple)[1] == [1, 2, 15]
    assert cut(list_of_tuple)[5] == [27]
    assert cut(list_of_tuple)[50] == []
    assert cut(list_of_tuple)[0] == [0, 3, 12]
    assert cut(list_of_tuple)[:2] == [(0, 1), (3, 2), (12, 15)]
Пример #2
0
def test_cut_list_of_list():
    assert cut(list_of_list)[3] == [3, 0, 21]
    assert cut(list_of_list)[1] == [1, 2, 15]
    assert cut(list_of_list)[5] == [27]
    assert cut(list_of_list)[50] == []
    assert cut(list_of_list)[0] == [0, 3, 12]
    assert cut(list_of_list)[:2] == [[0, 1], [3, 2], [12, 15]]
Пример #3
0
def test_complex_cuts_list_of_list_of_list_of_list():
    assert cut(list_of_list_of_list_of_list)[1] == [
        [[10, 11, 12], [13, 14, 15], [16, 17, 18]],
        [[28, 29, 30], [31, 32, 33], [34, 35, 36]]]

    assert cut(list_of_list_of_list_of_list)[1, 1] == [
        [13, 14, 15], [31, 32, 33]
    ]
    assert cut(list_of_list_of_list_of_list)[1, 1] == (
        cut(list_of_list_of_list_of_list)[1][1])

    assert cut(list_of_list_of_list_of_list)[1, 1, 1] == [
        14, 32
    ]
    assert cut(list_of_list_of_list_of_list)[1, 1, 1] == (
        cut(list_of_list_of_list_of_list)[1][1][1])

    assert cut(list_of_list_of_list_of_list)[1, 1, 1, 1] == []

    assert cut(list_of_list_of_list_of_list)[...] == list(range(1, 37))
Пример #4
0
]

happyPath = os.path.join(dirPath, baseName, 'happy.gif')
unhappyPath = os.path.join(dirPath, baseName, 'unhappy.gif')
gifList = [
    happyPath,
    unhappyPath,
]

filePath = os.path.join(dirPath, baseName, fileName)
headPath = os.path.join(dirPath, baseName, 'head.png')
srcPath = os.path.join(dirPath, baseName, 'src')
targetPath = os.path.join(dirPath, baseName, 'target')
ausPath = os.path.join(dirPath, baseName, 'aus.pkl')

left, top = cut(filePath, headPath)
# cutter

ausget(os.path.join(dirPath, baseName))
# ausgetter

for i in range(len(ausList)):
    if (not os.path.exists(srcPath)):
        os.mkdir(srcPath)
    transform(num, headPath, srcPath, ausPath, ausList[i])
    # transformer

    if (not os.path.exists(targetPath)):
        os.mkdir(targetPath)
    rebuild(num, left, top, filePath, srcPath, targetPath)
    # rebuilder
Пример #5
0
def test_cut_list_of_dict():
    assert cut(list_of_dict)['a'] == ['a', None, 0]
    assert cut(list_of_dict)['a'][2] == 0
    assert cut(list_of_dict)['a', 2] == []
    assert cut(list_of_dict).a == ['a', None, 0]
    assert cut(list_of_dict)['b'] == [2, 3]
    assert cut(list_of_dict).b == [2, 3]
    assert cut(list_of_dict)['j'] == []
    assert cut(list_of_dict).j == []
    assert cut(list_of_dict)[5] == ['foo']
    assert cut(list_of_dict)[2] == []
    assert cut(list_of_dict)[0] == [0]
Пример #6
0
def test_call():
    cls = [Cls('a'), Cls('r'), Cls('s')]
    assert cut(cls).get_upper_attr() == list('ARS')
    assert cut('cu7').isalpha() == [True, True, False]
Пример #7
0
def test_chain():
    cls = [Cls([Cls('a'), Cls('h')]), Cls([Cls('s'), Cls('u')])]
    assert cut(flatten(cut(cls).attr)).attr == list('ahsu')
    assert cut(cls).attr._.attr == list('ahsu')

    assert cut(cut(cls).attr) == cut(cls).attr
    assert cut(cut(cls).attr)._.attr == cut(cls).attr._.attr
    assert cut(cut(cls).attr._) == cut(cls).attr._
    assert cut(cut(cls).attr._)._ellipsis_at_next == cut(
        cls).attr._._ellipsis_at_next
    assert cut(cut(cls).attr._).attr == cut(cls).attr._.attr
    assert cut(cut(cut(cls).attr)._).attr == cut(cls).attr._.attr
Пример #8
0
def test_cls():
    cls = [Cls('a'), Cls('r'), Cls('s')]
    assert cut(cls).attr == list('ars')
Пример #9
0
def test_complex_cuts_list_of_dicts_of_list_of_dicts():
    assert cut(list_of_dict_of_list_of_dict)['A', ..., 'b'] == [1, 12]
    assert cut(list_of_dict_of_list_of_dict)['B', ..., 'b'] == ['u', 17, '']
    assert cut(list_of_dict_of_list_of_dict)['B', ..., 'a', 'T'] == [12, 4]
    assert cut(list_of_dict_of_list_of_dict)['B', 1:, ..., 'a', 'T'] == [12]
    assert cut(list_of_dict_of_list_of_dict)['B', :1, ..., 'a', 'T'] == [4]
Пример #10
0
def test_complex_cuts_list_of_dicts_of_dicts():
    assert cut(list_of_dict_of_dict)['A', 'b'] == [1, '']
    assert cut(list_of_dict_of_dict)['B', 'b'] == [12, 'u', 17]
    assert cut(list_of_dict_of_dict)['B', 'a', 'T'] == [12, 4]
Пример #11
0
def test_cut_list_of_obj():
    assert cut(list_of_obj)['at1'] == [1, 2, [2., 4]]
    assert cut(list_of_obj).at1 == [1, 2, [2., 4]]
    assert cut(list_of_obj)['at2'] == [23, 'bar', 23, {}]
    assert cut(list_of_obj)['at3'] == [None, None]
    assert cut(list_of_obj)['at5'] == []
Пример #12
0
def test_cut_cut():
    assert cut(list_of_dict) == list_of_dict
    assert cut(list_of_dict) == cut(cut(list_of_dict))
    assert cut(list_of_dict)['a'] == cut(cut(list_of_dict))['a']
    assert repr(cut(list_of_dict)) == repr(list_of_dict) + '*'
    assert repr(cut(list_of_dict)['a']) == "['a', None, 0]" + '.'
Пример #13
0
            print('Delete full video, id:', prev_id)
            prev_id_wav = prev_id + '.wav'
            prev_id_mp4 = prev_id + '.mp4'
            prev_audio_full = os.path.join(full_audio_dir, prev_id_wav)
            prev_video_full = os.path.join(full_video_dir, prev_id_mp4)
            if os.path.exists(prev_audio_full):
                os.remove(prev_audio_full)
            if os.path.exists(prev_video_full):
                os.remove(prev_video_full)
        prev_id = id
        # Download full video and audio
        download(id, full_video_path, full_audio_path)

        # Cut out target portion of video and audio
        # Also, save audio as numpy
        cut(full_video_path_ext, cut_video_path_ext, full_audio_path_ext,
            cut_audio_path_ext, start, end, args.sr, audio_np_path)

        vc = cv2.VideoCapture(cut_video_path_ext)

        # If FPS is not 25, resample video.
        if vc.get(cv2.CAP_PROP_FPS) != args.fps:
            print('Resample video..')
            fps_int = int(args.fps)
            resample_command = 'ffmpeg -y -i ' + cut_video_path_ext + \
                               ' -r ' + str(fps_int) + \
                               ' -c:v libx264 -b:v 3M -strict -2 -movflags faststart ' \
                               + cut_video_path + '_resampled.mp4'
            subprocess.call(resample_command, shell=True)

            os.remove(cut_video_path_ext)
            os.rename(cut_video_path + '_resampled.mp4', cut_video_path_ext)
Пример #14
0
'''

import bs4
import requests

from cutter import cut

# 初始化
s = requests.Session()
form_data = {'action': 'save', 'from_domain': 'i', 'isread': 'on', 'lang': 'c'}
form_data['loginname'] = input('username:'******'password'] = input('password:'******'password'] = getpass('password:'******'https://login.51job.com/login.php'
r = s.post(url, form_data, cut('header'))


def write(n):
    url = 'https://search.51job.com/list/020000,000000,0000,00,9,99,%25E5%2589%258D%25E7%25A8%258B%25E6%2597%25A0%25E5%25BF%25A7%2B-%25E4%25BB%25A3%25E6%258B%259B%25E8%2581%2598%2B-51Job%25E6%258B%259B%25E8%2581%2598%25E4%25BC%259A,1,' + n + '.html?lang=c&stype=1&postchannel=0000&workyear=99&cotype=99&degreefrom=99&jobterm=99&companysize=99&lonlat=0%2C0&radius=-1&ord_field=0&confirmdate=9&fromType=&dibiaoid=0&address=&line=&specialarea=00&from=&welfare='
    r = s.get(url)
    content = r.content.decode('gbk')
    soup = bs4.BeautifulSoup(content, 'html.parser')
    content = soup.body.find_all('div', class_='el')[16:65]
    for x in content:
        with open('information', 'a') as fp:
            fp.write(str(x.text))
            fp.write('\n')


write('1')