示例#1
0
def tag_page(topic):
    line = "<tr><td>{0} " \
    + "<td><a href='/threads/{0}/{1}'>{5}</a>" \
    + "<td>{4}"
    result = []
    ot = "".join(topic)
    if "+" in topic:
        topic = topic.split("+")
    else:
        topic = [topic]
    result.append("<div><h1> #" + " #".join(topic) + "</h1>")
    result.append(" <a href='/create/" + ot + "'>+ create new</a><br>")
    result.append("<i>Note: tags can be combined using the "
                  "+ (plus sign) in the URL</i></div>")
    result.append("<p><table>")
    result.append("<tr><th>origin<th>title<th>replies")
    threads = tags_threads(topic)
    with open("./threads/list.txt") as site:
        site = site.read().splitlines()
    site = [s.split(" ") for s in site]
    site = [[*s[:5], " ".join(s[5:])] for s in site if [s[0], s[1]] in threads]
    result[0] += " (" + str(len(site)) + " threads)</h1>"
    test = "\n".join([line.format(*t) for t in site])
    result.append(test)
    result.append("</table>")
    result = p.mk("\n".join(result))
    return result
示例#2
0
	def setsettings(self, options):
		""" set utorrent settings. i.e max_ul_rate=10 """
		settings = re.sub('\s+', '', options[0])

		req = '&action=setsetting'
		splitted = settings.split('&')
		for opts in splitted:
			try:
				(setting, value) = opts.split('=')
			except:
				print "[Error]: Failed to parse `{0}`. exiting.".format(options[0])
				sys.exit(0)

			# build request string
			req += "&s=" + setting + "&v=" + value

		self.__request(req)
示例#3
0
文件: atom.py 项目: 153/multichan
def ldthread(host, thread):
    hosts = []
    data = []
    thread_dir = "/".join(["./threads", host, thread])
    index = thread_dir + "/list.txt"
    with open(index, "r") as index:
        index = index.read().splitlines()
    index = [i.split(" ") for i in index]
    hosts = list(set([i[0] for i in index]))
    files = ["/".join([thread_dir, host + ".txt"]) for host in hosts]
    for n, i in enumerate(files):
        with open(i, "r") as slice:
            slice = slice.read().splitlines()
        slice = [[hosts[n], *s.split("<>")] for s in slice]
        data.append(slice)
    data = [x for y in data for x in y]
    data.sort(key=lambda x: x[1], reverse=1)
    for n, d in enumerate(data):
        data[n][2] = unix2atom(d[1])
        data[n].insert(3, f"Reply from {d[0]}")
    return data
示例#4
0
def take_visit_first_action_time(s):
    """
        Take index of visitor from log_visit from value of still_visiting directory
    """
    return s.split('|')[2]
示例#5
0
def take_index(s):
    """
        Take index of visitor from log_visit from value of still_visiting directory
    """
    return s.split('|')[0]
示例#6
0
def take_server_time(s):
    """
        Take server time from value of still_visiting directory
    """
    return s.split('|')[1]
示例#7
0
def take_visit_first_action_time(s):
    """
        Take index of visitor from log_visit from value of still_visiting directory
    """
    return s.split('|')[2]
示例#8
0
def take_index(s):
    """
        Take index of visitor from log_visit from value of still_visiting directory
    """
    return s.split('|')[0]
示例#9
0
def take_server_time(s):
    """
        Take server time from value of still_visiting directory
    """
    return s.split('|')[1]