示例#1
0
def genSrt(srt_dict):
    keys = loadstr(root_path + 'keyframes_santa.list')
    lines = []
    lines.append(1)
    num = double(keys[0][1:5]) - 1
    hour = '00'
    minute = str(int(num / 5 / 60)).zfill(2)
    second = str(num / 5.0 % 60).replace('.', ',').zfill(4)
    start_t = hour + ':' + minute + ':' + second + '00'
    srt = srt_dict[root_path + 'data/santa/key/' + keys[0]]
    for k, i in zip(keys[1:], range(1, len(keys))):
        num = double(k[1:5])
        minute = str(int(num / 5 / 60)).zfill(2)
        second = str(num / 5.0 % 60).replace('.', ',').zfill(4)
        end_t = hour + ':' + minute + ':' + second + '00'
        lines.append(start_t + ' --> ' + end_t)
        lines.append(srt)
        lines.append('')
        start_t = hour + ':' + minute + ':' + second + '25'
        srt = srt_dict[root_path + 'data/santa/key/' + k]
        lines.append(int(i) + 1)
    end_t = hour + ':' + minute + ':' + second + '25'
    lines.append(start_t + ' --> ' + end_t)
    lines.append(srt)
    writestr(root_path + 'santa.srt', lines)
示例#2
0
def writeList():
    root_path = '/home/gcao/bash_cmd/music/'
    filenames = loadstr(root_path + 'mylist.txt')
    lst = []
    for f in filenames:
        lst.append('file ' + '\'' + root_path + f + '\'')
    writestr('mylist2.txt', lst)
示例#3
0
def genSrt(srt_dict):
    keys = loadstr(root_path + 'keyframes_santa.list')
    lines = []
    lines.append(1)
    num = double(keys[0][1:5]) -1 
    hour = '00'
    minute = str(int(num/5/60)).zfill(2)
    second = str(num/5.0%60).replace('.',',').zfill(4)
    start_t = hour + ':' + minute + ':' + second + '00'
    srt = srt_dict[root_path + 'data/santa/key/' + keys[0]]
    for k,i in zip(keys[1:], range(1,len(keys))):
        num = double(k[1:5]) 
        minute = str(int(num/5/60)).zfill(2)
        second = str(num/5.0%60).replace('.',',').zfill(4)
        end_t = hour + ':' + minute + ':' + second + '00'
        lines.append(start_t + ' --> ' + end_t)
        lines.append(srt)
        lines.append('')
        start_t = hour + ':' + minute + ':' + second + '25'
        srt = srt_dict[root_path + 'data/santa/key/' + k]
        lines.append(int(i)+1)
    end_t = hour + ':' + minute + ':' + second + '25'
    lines.append(start_t + ' --> ' + end_t)
    lines.append(srt)
    writestr(root_path + 'santa.srt', lines)
示例#4
0
def parseOutput():
    srt_dict = {}
    lst = loadstr(root_path + 'caplog.txt')
    for l in lst:
        if '.jpg' in l:
            img_orig = l.split()[1][1:-1]
        elif ':' in l:
            srt = l.split(':')[1][1:]
            srt_dict[img_orig] = srt
    return srt_dict
示例#5
0
def parseOutput():
    srt_dict = {}
    lst = loadstr(root_path + 'caplog.txt')
    for l in lst:
        if '.jpg' in l:
            img_orig = l.split()[1][1:-1]
        elif ':' in l:
            srt = l.split(':')[1][1:]
            srt_dict[img_orig] = srt
    return srt_dict
示例#6
0
import numpy as np
import pandas as pd
import sys
sys.path.insert(0, "/home/gcao/Projects/retrieval/misc/")
from fileproc import loadstr
from pdb import set_trace

def count_trees_brute_force(data, toright, tobelow):
    idx = 0 
    cnt = 0
    for entry in data[::tobelow]:
        if idx >= len(entry):
            idx = idx - len(entry)
        if entry[idx] == '#':
            cnt += 1
        idx += toright 
    return cnt

if __name__ == '__main__':
    data = loadstr('data/2020_d03_input.txt')
    nums = [1,3,5,7]
    cnt = 1
    for n in nums:
        cnt *= count_trees_brute_force(data, n, 1)
    cnt *= count_trees_brute_force(data, 1, 2)
    print(cnt)
示例#7
0
def remove():
    lst = loadstr('status.txt')
    for l in lst:
        if 'deleted' in l:
            command = 'git rm' + l.split(':')[1]
            subprocess.call(command, shell=True)
示例#8
0
def copyKeyframes():
    from shutil import copyfile
    keys = loadstr(root_path + 'keyframes_santa.list')
    for k in keys:
        copyfile(root_path + 'data/santa/img/'+k, root_path + 'data/santa/key/'+k)
示例#9
0
def copyKeyframes():
    from shutil import copyfile
    keys = loadstr(root_path + 'keyframes_santa.list')
    for k in keys:
        copyfile(root_path + 'data/santa/img/' + k,
                 root_path + 'data/santa/key/' + k)
示例#10
0
def copyKeyframes():
    from shutil import copyfile
    keys = loadstr(root_path + 'keyframes_percurso_1.list')
    for k in keys:
        copyfile(root_path + 'data/percurso_1/img/'+k, root_path + 'data/percurso_1/key/'+k)