Exemplo n.º 1
0
def get_cites_pubs_on_pub(driver, pub, main_index):
    """Получаем все публикации, в которых цитируется указанная"""
    driver.get(_CITES.format(pub.id_scholarcitedby))
    utils.check_captcha(driver)
    utils.unchecked_citations(driver)

    for z in range(1, _CONTINUE_INFO['citations_page']):
        time.sleep(0.5)
        if not utils.next_page(driver):
            print('Такой страницы с публикациями нет')
            break

    i = _CONTINUE_INFO['citations_page'] - 1
    while True:
        i = i + 1
        _CONTINUE_INFO['citations_page'] = i
        _CONTINUE_INFO['last_index_in_result'] = saver.get_last_index()
        saver.save_in_file(_CONTINUE_INFO, _CONTINUE_FILE)
        add_pubs_in_lib(driver)
        pubs = get_pubs_from_lib(driver)
        close_window(driver)
        for citi in pubs:
            saver.save(_RESULT_FILE, citi, main_index)
        if not utils.next_page(driver) or i > 9:
            break
Exemplo n.º 2
0
def save_file(vaults, path):
    try:
        save(vaults, path)
        os.startfile(path)
        print('=' * 50)
        print('[+]Info saved to your desktop.')
        print('=' * 50)
    except Exception:
        print("Error with saving.Try to re-enter username.")
Exemplo n.º 3
0
 def dump_sign(self):
     curv = self.curves.selected
     if curv == None: return
     path = []
     for u in np.linspace(0, len(curv) - 1, len(curv) * 16):
         path.append(curv.get_ptn(u))
     trans = np.resize(milling_paths.TRANS, 4)
     trans[3] = 0
     scale = milling_paths.SCALE
     proc = lambda p: (p + trans) * scale
     saver.save(-1, '05_sign.k4', path, pre=proc)
Exemplo n.º 4
0
	def dump_sign( self ) :
		curv = self.curves.selected
		if curv == None : return
		path = []
		for u in np.linspace(0,len(curv)-1,len(curv)*16) :
			path.append( curv.get_ptn( u ) )
		trans = np.resize( milling_paths.TRANS , 4 )
		trans[3] = 0
		scale = milling_paths.SCALE
		proc = lambda p : (p + trans)*scale
		saver.save(-1,'05_sign.k4',path, pre = proc )
Exemplo n.º 5
0
    def __init__(self, curves):
        Node.__init__(self, Lines(), (1.0, 0.5, 0.0))

        self.curves = curves
        self.paths = []

        self.init_r = HUGE_DRILL / 2.0 / SCALE
        self.flat_r = FLAT_DRILL / 2.0 / SCALE
        self.exac_r = SMALL_DRILL / 2.0 / SCALE

        print 'Init drill: ', self.init_r
        print 'Flat drill: ', self.flat_r
        print 'Exact drill: ', self.exac_r

        self.gen_paths()

        proc = lambda p: (p + TRANS) * SCALE + np.array((0, 0, -SMALL_DRILL))

        save(0, '01_init.k16', self.paths, pre=proc)
        save(1, '02_border.f12', self.paths, pre=proc)
        save(2, '03_flat.f12', self.paths, pre=proc)
        save(3, '04_exact.k8', self.paths, pre=proc)

        save_commpressed(0, '11_init_small.k16', self.paths, pre=proc)
        save_commpressed(1, '12_border_small.f12', self.paths, pre=proc)
        save_commpressed(2, '13_flat_small.f12', self.paths, pre=proc)
        save_commpressed(3, '14_exact_small.k8', self.paths, pre=proc)

        self.set_data(self.paths)

        np.set_printoptions(suppress=True)
Exemplo n.º 6
0
	def __init__( self , curves ) :
		Node.__init__( self , Lines() , (1.0,0.5,0.0) )

		self.curves = curves
		self.paths = []

		self.init_r = HUGE_DRILL / 2.0 / SCALE
		self.flat_r = FLAT_DRILL / 2.0 / SCALE
		self.exac_r = SMALL_DRILL / 2.0 / SCALE 

		print 'Init drill: ' ,self.init_r 
		print 'Flat drill: ' ,self.flat_r
		print 'Exact drill: ' ,self.exac_r

		self.gen_paths()

		proc = lambda p : (p + TRANS)*SCALE + np.array((0,0, -SMALL_DRILL))

		save(0,'01_init.k16'   , self.paths , pre = proc )
		save(1,'02_border.f12' , self.paths , pre = proc )
		save(2,'03_flat.f12'   , self.paths , pre = proc )
		save(3,'04_exact.k8'   , self.paths , pre = proc )

		save_commpressed(0,'11_init_small.k16'   ,  self.paths ,pre = proc )
		save_commpressed(1,'12_border_small.f12' ,  self.paths ,pre = proc )
		save_commpressed(2,'13_flat_small.f12'   ,  self.paths ,pre = proc )
		save_commpressed(3,'14_exact_small.k8'   ,  self.paths ,pre = proc )

		self.set_data( self.paths )

		np.set_printoptions(suppress=True)
Exemplo n.º 7
0
 def file_save():
     """
     Function for saving field to file
     """
     file = tkinter.filedialog.asksaveasfile(mode='w',
                                             defaultextension=".sav")
     if file:
         file.write(saver.save(self.game.field, self.game.player))
         file.close()
Exemplo n.º 8
0
def get_pubs_with_cities(driver):
    """Соединяем публикации с их цитирующими публикацями"""
    indexes = []
    pubs = get_pubs_from_lib(driver)
    for pub in pubs:
        indexes.append(saver.save(_RESULT_FILE, pub))

    _CONTINUE_INFO['last_index_in_result'] = saver.get_last_index()
    saver.save_in_file(_CONTINUE_INFO, _CONTINUE_FILE)

    for p in range(_CONTINUE_INFO['cities_index'], len(indexes)):
        _CONTINUE_INFO['cities_index'] = p
        saver.save_in_file(_CONTINUE_INFO, _CONTINUE_FILE)
        if pubs[p].citedby != 0:
            get_cites_pubs_on_pub(driver, pubs[p], indexes[p])
            _CONTINUE_INFO['citations_page'] = 1
    _CONTINUE_INFO['cities_index'] = 0
Exemplo n.º 9
0
 def make_multiplayer_move(self, first_player):
     """
     Method for making multiplayer move
     :param first_player: bool
     """
     if first_player:
         while not self.client.received:
             pass
         self.field, self.player = saver.load(self.client.recv_str)
     else:
         data = saver.save(self.field, self.player)
         self.client.send(data)
         while not self.client.received:
             pass
         self.field, self.player = saver.load(self.client.recv_str)
         self.previous_player = not self.player
     self.client.recv_str = ''
     self.client.received = False
Exemplo n.º 10
0
    def run(self, max_iter, solutions, print_all=False):
        bees = [
            Bee(self.world, self.neighbor_function, self.fitness_function)
            for x in range(0, self.n_of_bees)
        ]
        best_solution = None
        best_solution_overall = None
        best_solution_fitness_overall = 0
        worst_solution_fitness_overall = 10000
        best_solution_iteration = 0
        iteration = 0

        best_fitnesses = []

        while iteration < max_iter:
            print("Iteration ", iteration + 1)
            solutions = self.iterate(bees, solutions, print_all)

            fitnesses = [
                self.fitness_function(self.world, x) for x in solutions
            ]
            fit_sol = list(zip(fitnesses, solutions))
            fit_sol.sort(key=lambda x: x[0], reverse=True)

            best_solution = fit_sol[0][1]
            if fit_sol[0][0] > best_solution_fitness_overall:
                best_solution_overall = best_solution
                best_solution_iteration = iteration + 1
                best_solution_fitness_overall = fit_sol[0][0]
                if fit_sol[-1][0] < worst_solution_fitness_overall:
                    worst_solution_fitness_overall = fit_sol[-1][0]
            print("Best fitness in iteration ", iteration + 1, " : ",
                  fit_sol[0][0], " solution: ", best_solution)
            iteration += 1
            best_fitnesses.append(fit_sol[0][0])

        saver.save(self.world, 'world')
        saver.save(best_fitnesses, 'fitness_history')
        saver.save(best_solution, 'best_solution')

        print('Worst fitness overall: ', worst_solution_fitness_overall)
        print('Best solution: ', best_solution_overall)
        print('Found in ', best_solution_iteration, ' iteration')
        print('Fitness: ', best_solution_fitness_overall)

        return best_solution, best_fitnesses
Exemplo n.º 11
0
def on_save():
    print('on_save: saving...')
    file = filedialog.asksaveasfilename(
        defaultextension='.jad')  # add some options here
    save(file, trigger_list)
Exemplo n.º 12
0
    text = []

    try:
        html_text = urllib.urlopen(urls[0]).read()
    except:
        print 'Error on:', urls[0]

    soup = BeautifulSoup(html_text)

    print 'URL:', urls[0]
    urls.pop(0)
    print 'Url Count:', len(urls)

    for tag in soup.findAll('p'):
        if tag.string != None:
            text.append(tag.string)

    for tag in soup.findAll('a', href=True):
        tag['href'] = urlparse.urljoin(start_url, tag['href'])
        print 'Tag:', tag['href']

        if url_check in tag['href'] and tag['href'] not in visited and not stop:
            urls.append(tag['href'])
            visited.append(tag['href'])

            if len(urls) >= 5000:
                stop = True

    save(text, FILE_NAME)

print '---------------------'
Exemplo n.º 13
0
 def test_saver(self):
     field, player = self.load_identity()
     string = saver.save(field, player)
     field2, player2 = saver.load(string)
     self.assertEqual((field, player), (field2, player2))
 def save(self):
     saver.save([self._player, self._map], World.SAVE_DIR)
Exemplo n.º 15
0
        print(
            "step number:", t, "\tpercent done:",
            np.round((100.0 * (t - starting_timestep + 1)) /
                     (final_timestep - starting_timestep + 1), 2),
            "\ttime per step estimate:",
            np.round(
                np.mean(time_taken[max(0,
                                       len(time_taken) - 10):len(time_taken)]),
                3), "\ttime estimate:",
            np.round(
                np.mean(time_taken[max(0,
                                       len(time_taken) - 50):len(time_taken)])
                * (final_timestep - t), 1))

    # make save
    saver.save(vals)
    print("he", all_neurons[0].voltage_history.shape)
    # make predefined data plots or saves
    not_first_plot = False
    print(Interpreter.predef_output_lines)
    ret = 1
    any_plots = False
    for line in Interpreter.predef_output_lines:
        ret = generate_save_or_plot(line)
        if ret == 0:
            break
        if ret == 2:
            not_first_plot = True
            any_plots = True

    if any_plots:
Exemplo n.º 16
0
 def save(self, fn):
     '''Save project'''
     saver.save(fn)
Exemplo n.º 17
0
reddit = praw.Reddit(user_agent=user_agent)

subreddit = reddit.get_subreddit('askreddit')

text = []

for submission in subreddit.get_new(limit=5000):
    print 'Title:', submission.title
    print "Text: ", submission.selftext
    print "Score: ", submission.score

    text.append(submission.title)
    text.append(submission.selftext)

    try:
        submission.replace_more_comments(limit=50, threshold=0)
    except:
        continue

    for comment in submission.comments:
        try:
            print 'Comment Body:', comment.body
            text.append(comment.body)
        except:
            pass

    print "---------------------------------\n"

    save(text, 'new_data.txt')
    text = []
Exemplo n.º 18
0
 def save_streaming_data(time, rdd):
     if not rdd.isEmpty():
         saver.save(sqlc, config, 'news', rdd)
Exemplo n.º 19
0
import pygame

import funcs
import glbl_nms
import saver

pygame.init()

clock = pygame.time.Clock()
pygame.display.set_caption("MIPT study")

saver.load()  # загрузка сохранения

while glbl_nms.RUN:
    clock.tick(30)  # FPS
    funcs.rndm_events()
    funcs.key_checker()
    funcs.stat_decrease()  # decrease stats
    funcs.timer()  # anim timer
    funcs.a_u_ok()  # checking stats for borders
    funcs.draw_screen()

saver.save()  # Сохраняем

pygame.quit()
Exemplo n.º 20
0
    else:
        return None


# main
import saver
numRun = 4
dataList = []

for i in range(0, numRun):
    print('Run #: ', i, '...')
    # First episode
    sc0 = generateData(i)
    if sc0 is not None:
        # if the list is not empty
        sc = sc0
        saver.save(sc)  # save data
        if not dataList:
            for robot in sc.robots:
                dataList.append(robot.data)
        else:
            for j in range(len(sc.robots)):
                dataList[j].append(sc.robots[j].data)

for j in range(1, len(sc.robots)):
    dataList[0].append(dataList[j])
dataList[0].store()

#for j in range(len(sc.robots)):
#    dataList[j].store()
Exemplo n.º 21
0
 def test_saver(self):
     field, player = self.load_identity()
     string = saver.save(field, player)
     field2, player2 = saver.load(string)
     self.assertEqual((field, player), (field2, player2))
Exemplo n.º 22
0
        best_friends = []
        for i, worker in enumerate(workers):
            print('\r    calculating friends for worker ',
                  i + 1,
                  '/',
                  len(workers),
                  end='')
            best_friends.append(
                (worker, best_friend_for_worker(worker, workers)))
        best_workers = []
        for i, seat in enumerate(seats):
            print('\r    calculating workers for seat ',
                  i + 1,
                  '/',
                  len(seats),
                  end='')
            best_workers.append(
                (seat, best_worker_for_seat(seat, best_friends)))
        print('\r    Done kmining! Reorganising output...', end='')

        best_workers = list(
            reversed(sorted(best_workers, key=lambda x: x[1][0][1])))

        output_dict = save(workers, best_workers,
                           'outputs/result_' + file.split('/')[-1])
        print('\r    Saved! score: ', end='')
        score = score(sizes[fi], output_dict,
                      {worker.id: worker
                       for worker in workers})
        print(score)
def save(player_pos):
    logger.debug('Try to save game')
    saver.save([player_pos, world], SAVE_DIR)
    logger.debug('Game saved successfully')