Example #1
0
def compare(course,element):
   results = funct.compareQuery(course,element)
   print(results)
   if results == True:
      # add discord notification here
      print("data exist")
      return True
   else:
      print("data not exist")
      funct.insert(course,element)
      return False
def de_bruijn_kmers(kmers):
    graph = {}
    for kmer in kmers:
        prefix = kmer[0:-1]
        suffix = kmer[1:]
        functions.insert(graph, prefix, suffix)

    output = ''
    keys = list(graph.keys())
    keys.sort()
    for key in keys:
        l = ','.join(graph[key])
        output += key + ' -> ' + l + '\n'
    return output
Example #3
0
def upload():
    if request.method == 'POST':
        if 'file' not in request.files:
            return redirect(request.url)
    file = request.files['file']

    if file.filename == '':
        return redirect(request.url)
    if file:
        filename = 'BSA-{date:%Y-%m-%d_%H:%M:%S}.xls'.format(
            date=datetime.datetime.now())
        file.save(os.path.join(UPLOAD_FOLDER, filename))
        insert(filename)
        return jsonify('ok')
Example #4
0
 def insert(self,text):
     global img
     try:
         img=Image.open(functions.insert())
         img.save("trash.jpg")
         self.show_picture('trash.jpg')
         global flag
         flag = True
     except:
         pass
     return
Example #5
0
def compile_user_input():
    '''
    (1) Asks user for a list of intervals
    (2) Parses and merges that input
    (3) Asks user for one interval at a time to insert and merge
    '''

    user_input = ''
    successful_first_list = 0
    intervals = []
    merged_intervals = []
    parsed_input = []

    while successful_first_list == 0 and user_input != 'quit':  #if user hasn't yet input a valid interval list or quit
        user_input = str(input("List of intervals? "))
        if user_input == 'quit':
            pass
        else:
            try:
                parsed_input = m.parse_interval_input(user_input)
                try:
                    intervals = m.Make_intervals(parsed_input)
                    try:
                        if intervals:  #only try to merge intervals if you made valid intervals
                            merged_intervals = m.mergeOverlapping(intervals)
                            successful_first_list = 1
                    except:
                        if intervals:  #only print merge errors if you made the intervals
                            print('Unable to merge intervals in the input')
                except AssertionError as err:
                    print({0}.format(err))
            except ValueError as err:
                print('Could not parse input. Error details: {0}'.format(err))
    else:

        newint = ''

        while newint != 'quit' and user_input != 'quit':
            newint = str(input("Interval? "))
            if newint == 'quit':
                break
            else:
                try:
                    new_interval = i.Interval(newint)
                    inserted_intervals = m.insert(merged_intervals,
                                                  new_interval)
                    print(inserted_intervals)
                except AssertionError:
                    print('Invalid interval')
Example #6
0
def compile_user_input():
    """
    (1) Asks user for a list of intervals
    (2) Parses and merges that input
    (3) Asks user for one interval at a time to insert and merge
    """

    user_input = ""
    successful_first_list = 0
    intervals = []
    merged_intervals = []
    parsed_input = []

    while successful_first_list == 0 and user_input != "quit":  # if user hasn't yet input a valid interval list or quit
        user_input = str(input("List of intervals? "))
        if user_input == "quit":
            pass
        else:
            try:
                parsed_input = m.parse_interval_input(user_input)
                try:
                    intervals = m.Make_intervals(parsed_input)
                    try:
                        if intervals:  # only try to merge intervals if you made valid intervals
                            merged_intervals = m.mergeOverlapping(intervals)
                            successful_first_list = 1
                    except:
                        if intervals:  # only print merge errors if you made the intervals
                            print("Unable to merge intervals in the input")
                except AssertionError as err:
                    print({0}.format(err))
            except ValueError as err:
                print("Could not parse input. Error details: {0}".format(err))
    else:

        newint = ""

        while newint != "quit" and user_input != "quit":
            newint = str(input("Interval? "))
            if newint == "quit":
                break
            else:
                try:
                    new_interval = i.Interval(newint)
                    inserted_intervals = m.insert(merged_intervals, new_interval)
                    print(inserted_intervals)
                except AssertionError:
                    print("Invalid interval")
Example #7
0
def test_insert():
    patch1 = Patch2D(1, 1, 2, 2)
    patch2 = Patch2D(0, 0, 3, 3)

    patchSet = set()
    overlapSet = set()

    functions.insert(patch1, patchSet, overlapSet)
    assert len(patchSet) == 1

    functions.insert(patch2, patchSet, overlapSet)
    assert len(patchSet) == 5
    assert len(overlapSet) == 1

    assert functions.getArea(patchSet) == 9
    assert functions.getArea(overlapSet) == 1

    # checking if another overlap breaks anything
    functions.insert(patch1, patchSet, overlapSet)
    assert len(patchSet) == 5
    assert len(overlapSet) == 1

    assert functions.getArea(patchSet) == 9
    assert functions.getArea(overlapSet) == 1
Example #8
0
 def test_insert(self):
     self.assertEqual(str(m.insert(self.interval_list_input, self.interval_insert)), str(self.interval_insert_output))
def ui_insert(storage, cmd):
    day = int(cmd[1])
    value = int(cmd[2])
    tr_type = cmd[3]
    description = cmd[4]
    insert(storage, day, value, tr_type, description)
def test_insert():
    day = 23
    storage = {day: [[100, "out", "pizza"], [1000, "in", "salary"]]}
    insert(storage, 23, 150, "out", "jewlery")
    assert get_trans(storage, day, 2) == [150, "out", "jewlery"]
Example #11
0
import functions
from collections import defaultdict
#dic = defaultdict(list)
dic = {}
'''node = list(input("Enter the nodes ").split())
for i in node:
  lis=[]
  lis=input("Enter the nodes linked to node "+i).split()
  dic[i]=lis
print(functions.edges(dic))'''
while True:
    n = int(input("1-insert edge\n2-delete edge\n3-delete node\n4-exit\n"))
    if (n == 1):
        u, v = input("Enter the edge to be inserted  ").split()
        functions.insert(dic, u, v)
    elif (n == 2):
        u, v = input("Enter the edge to be deleted  ").split()
        functions.deleteedge(dic, u, v)
    elif (n == 3):
        u = input("Enter the node to be deleted  ")
        functions.deletenode(dic, u)
    else:
        break
# this file is used to test and show basic database functionality in terminal
import functions
import time

print("Running driver.py")

# create table
import create_table

# insert items into the table
print("Inserting items into table")
time.sleep(5)
functions.insert("Harry Potter", "J.K. Rowling", "Fiction", "10", "4.1")
functions.insert("Cat in the Hat", "Dr. Seuss", "Fiction", "5", "4.6")
functions.insert("Wocket in my Pocket", "Dr. Seuss", "Fiction", "4", "3.7")

# return a specific item from the table
print("Getting Item from database:")
time.sleep(2)
print(functions.get_item("Harry Potter", "J.K. Rowling"))
print("")

# update an item in the table and return it
print("Updating previous item and returning it:")
time.sleep(2)
functions.update_item("Harry Potter", "J.K. Rowling", "NumInStock", "22")
print(functions.get_item("Harry Potter", "J.K. Rowling"))
print("")

# return items from a certain Author in a table
print("Getting all books by Dr. Seuss:")
Example #13
0
    with open(i, 'wb') as csv_file:
        writer = csv.writer(csv_file)
        writer.writerow(['artists ', 'songs ', 'time'])
        writer.writerows(x)


schedule.every().hour.do(write_log)
rest_url = 'http://www.radio21.ro/track.json'
database_check = get_db_song()

if database_check is None:
    previous_songs = get_song(rest_url)
    previous_song = previous_songs[0]['track']
    previous_song_artist = previous_songs[0]['artist']
    ro_time = get_local_time()
    insert(previous_song_artist, previous_song, ro_time)

song_db = get_db_song()

while True:
    schedule.run_pending()
    time.sleep(60)
    current_songs = get_song(rest_url)
    current_song = current_songs[0]['track']
    current_song_artist = current_songs[0]['artist']

    if current_song != song_db:
        ro_time = get_local_time()
        insert(current_song_artist, current_song, ro_time)
        song_db = current_song
Example #14
0
 def test_insert(self):
     self.assertEqual(
         str(m.insert(self.interval_list_input, self.interval_insert)),
         str(self.interval_insert_output))
Example #15
0
for i in range(9):
    choice.append(None)
functions.createhash(choice)

user = input("Choose 'x' or 'o': ")
if user == 'x':
    comp = 'o'
else:
    comp = 'x'

available = [0, 1, 2, 3, 4, 5, 6, 7, 8]

if user == 'x':
    while len(available) >= 1:
        option = int(input('Choose location: '))
        functions.insert(choice, user, option, available)
        functions.createhash(choice)
        if functions.ifwon(choice):
            print('!!!!!!!!!YOU WON!!!!!!!!!!!!!')
            break
        functions.compinsert(choice, available, comp)
        functions.createhash(choice)
        if functions.ifwon(choice):
            print('!!!!!!!YOU LOSE!!!!!!!!!!!!!!')
            break
    else:
        print('!!!!!!MATCH TIED!!!!!!!!!!!')

if user == 'o':
    while len(available) >= 1:
        functions.compinsert(choice, available, comp)
Example #16
0
        history = functions.select(config.histories_1[0], cursor_bank)

        print("result len = %d | history len = %d" %
              (len(result), len(history)))

        #insert listener
        if (len(result) > len(history)):
            print("-- INSERT DETECTED --")
            for data in result:
                a = 0
                for dataHistory in history:
                    if (data[0] == dataHistory[0]):
                        a = 1
                if (a == 0):
                    print("-- RUN INSERT FOR ID = %d" % (data[0]))
                    functions.insert(config.histories_1[0], data, cursor_bank,
                                     db_bank)
                    functions.insert(config.histories_1[0], data, cursor_toko,
                                     db_toko)
                    functions.insert(config.tables_1[0], data, cursor_toko,
                                     db_toko)

        #delete listener
        if (len(result) < len(history)):
            print("-- DELETE DETECTED --")
            for dataHistory in history:
                a = 0
                for data in result:
                    if (dataHistory[0] == data[0]):
                        a = 1
                if (a == 0):
                    print("-- RUN DELETE FOR ID = %d" % (dataHistory[0]))
Example #17
0
from time import sleep as s
from functions import getID, getName, getWebsite, getScope, insert

id1 = getID()
x = 0

while(x != getID()):
	name = getName(id1)
	web = getWebsite(id1)
	scope = getScope(id1)
	s(1)
	insert(name, web, scope)
	id1 -= 1
	x += 1

###########################################
# created by Samuel Schatz                #
# github: https://github.com/sschatz1997  #
# email: [email protected]            #
###########################################