示例#1
0
 def __init__(self, mongo_name=None):
     self.mongo_wrapper = MongoWrapper(mongo_name)
     self.mono_db_names = self.mongo_wrapper.get_db_names()
     self.scenes_handler = Scene(self.mongo_wrapper)
     self.hypothesis_handler = Hypothesis(self.mongo_wrapper)
     self.objects_handler = Object(self.mongo_wrapper)
     self.active_data_type = self.scenes_handler
示例#2
0
def MapObject(object_map, obj):

  oid = obj['object_id']
  obj['id'] = oid
  del obj['object_id']

  if oid in object_map:
    object_ = object_map[oid]

  else:
    if 'attributes' in obj:
      attrs = obj['attributes']
      del obj['attributes']
    else:
      attrs = []
    if 'w' in obj:
      obj['width'] = obj['w']
      obj['height'] = obj['h']
      del obj['w'], obj['h']

    object_ = Object(**obj)

    object_.attributes = attrs
    object_map[oid] = object_

  return object_map, object_
示例#3
0
文件: views.py 项目: demvy/museum
def TempSave(request, id_number=0):
    try:
        project = Object.objects.get(id=int(id_number))
    except ObjectDoesNotExist:
        if id_number != 0:
            return HttpResponse('Об’єкт не існує.<br>Спробуйте інший id.')
        else:
            project = Object(name='Новий')
    if request.method == 'POST':
        form = TempSaveForm(request.POST, request.FILES)
        if form.is_valid():
            cd = form.cleaned_data
            act = Activity(time_stamp=dt.now(), aim=project, type='Приймання на тимчасове зберігання', actor=Custom.myUser.objects.get(username=request.user.username))
            act.save()
            project.reason = cd['reason']
            project.save()
            for (k, v) in cd.items():
                if k=='material':
                    v = unicode(v[1:-1].replace('u\'', '').replace('\'', ''))
                attr_assign = AttributeAssignment(attr_name=k, attr_value=v, attr_label=form.fields[k].label,
                                                  event_initiator=act, aim=project)
                attr_assign.save()
            return HttpResponseRedirect('/')
        else:
            return render(request, 'AddOnTs.html', {'form': form})
    else:
        data = {'name': project.name, 'is_fragment': project.is_fragment, 'amount': project.amount,
                'date_creation': project.date_creation, 'place_of_creation': project.place_of_creation,
                'author': project.author, 'technique': project.technique, 'material': project.material.decode('unicode-escape').split(', '),
                'size': project.size, 'condition': project.condition, 'condition_descr': project.condition_descr, 'description': project.description,
                'price': project.price, 'note': project.note}
        form = TempSaveForm(initial=data)
        return render(request, 'AddOnTs.html', {'form': form, 'label': 'Прийняти об’єкт на ТЗ'})
示例#4
0
def MapObject(object_map, obj):
    """
    Use object ids as hashes to `src.models.Object` instances. If item not
      in table, create new `Object`. Used when building scene graphs from json.
    """
    oid = obj['object_id']
    obj['id'] = oid
    del obj['object_id']

    if oid in object_map:
        object_ = object_map[oid]

    else:
        if 'attributes' in obj:
            attrs = obj['attributes']
            del obj['attributes']
        else:
            attrs = []
        if 'w' in obj:
            obj['width'] = obj['w']
            obj['height'] = obj['h']
            del obj['w'], obj['h']

        object_ = Object(**obj)

        object_.attributes = attrs
        object_map[oid] = object_

    return object_map, object_
示例#5
0
文件: views.py 项目: demvy/museum
def Passport(request, id_number):
    try:
        project = Object.objects.get(id=int(id_number))
    except ObjectDoesNotExist:
        if id_number != '0':
            return HttpResponse('Об’єкт не існує.<br>Спробуйте інший id.')
        else:
            project = Object(name='Новий')
    if request.method == 'POST':
        form = PassportForm(request.POST)
        if form.is_valid():
            cd = form.cleaned_data
            project.save()
            act = Activity(time_stamp=dt.now(), aim = project, type='Науково-уніфікований паспорт', actor=Custom.myUser.objects.get(username=request.user.username))
            act.save()
            for (k, v) in cd.items():
                if k=='material':
                    v = unicode(v[1:-1].replace('u\'', '').replace('\'', ''))
                attr_assign = AttributeAssignment(attr_name=k, attr_value=v, attr_label=form.fields[k].label,
                                                  event_initiator=act, aim=project)
                attr_assign.save()
            return HttpResponseRedirect('/')
        else:
            return render(request, 'AddOnTs.html', {'form': form, 'errors': form.errors})
    else:
        collection = get_attrib_assigns('Інвентарний облік', project, 'collection')
        ps_code = get_attrib_assigns('Приймання на постійне зберігання', project, 'PS_code')
        inventory_number = get_attrib_assigns('Інвентарний облік', project, 'inventory_number')
        spec_inventory_numb = get_attrib_assigns('Спеціальний інвентарний облік', project, 'spec_inventory_numb')
        old_inventory_numbers = get_attrib_assigns('Інвентарний облік' or 'Приймання на постійне зберігання',project, 'old_registered_marks')
        date_place_creation = ' '.join([project.date_creation, project.place_of_creation])
        date_place_detection = ' '.join([project.date_detection, project.place_detection])
        date_place_existence = ' '.join([project.date_existence, project.place_existence])
        source = get_attrib_assigns('Приймання на постійне зберігання', project, 'source')
        classify = get_attrib_assigns('Інвентарний облік', project, 'classify')
        typology = get_attrib_assigns('Інвентарний облік', project, 'typology')
        metals = get_attrib_assigns('Спеціальний інвентарний облік', project, 'metals')
        stones = get_attrib_assigns('Спеціальний інвентарний облік', project, 'stones')
        bibliography = get_attrib_assigns('Інвентарний облік', project, 'bibliography')
        data = {'collection': collection, 'PS_code': ps_code, 'inventory_number': inventory_number,
                'spec_inventory_numb': spec_inventory_numb, 'old_inventory_numbers': old_inventory_numbers,
                'identifier': project.identifier, 'storage': project.storage,
                'name': project.name, 'author': project.author, 'date_place_creation': date_place_creation,
                'date_place_detection': date_place_detection, 'date_place_existence': date_place_existence,
                'source': source, 'way_of_found': project.way_of_found, 'link_on_doc': project.link_on_doc,
                'classify': classify, 'typology': typology, 'amount': project.amount,
                'size': project.size, 'material': project.material.decode('unicode-escape').split(', '), 'technique': project.technique,
                'metals': metals, 'stones': stones, 'description': project.description,
                'condition': project.condition, 'condition_descr': project.condition_descr,
                'recomm_for_restauration': project.recomm_for_restauration,
                'transport_possibility': project.transport_possibility, 'price': project.price,
                'bibliography': bibliography}
        form = PassportForm(initial=data)
    return render(request, 'AddOnTs.html', {'form': form, 'label': 'Створити науково-уніфікований паспорт об’єкта'})
示例#6
0
def create_object(sender, title, url, time, **kwargs):
    title = title
    url = url
    time = time
    if not Object.objects.filter(url=url).exists():
        new_object = Object(
            title = title,
            url = url,
            time = time,
            branch = sender.__class__.__name__,
        )
        new_object.save()
示例#7
0
def setObject(request, flag, oid, mid, name, category):
    if request.user.is_authenticated():
        try:
            newName = replace(name, "_", " ")
            newCategory = replace(category, "_", " ")
            newMid = int(mid)
            o = Object(category=newCategory, name=newName, mid=Map.objects.get(mid=newMid), lock=False)
            o.save()
            #return success()
            return HttpResponse("insert_"+str(o.oid))
        except:
            return empty()
    return failure()
示例#8
0
def ParseGraphLocal(data, image, verbose=False):
  global count_skips
  objects = []
  object_map = {}
  relationships = []
  attributes = []

  for obj in data['objects']:
    object_map, o_ = MapObject(object_map, obj)
    objects.append(o_)
  for rel in data['relationships']:
    if rel['subject_id'] in object_map and rel['object_id'] in object_map:
      object_map, s = MapObject(object_map, {'object_id': rel['subject_id']})
      v = rel['predicate']
      object_map, o = MapObject(object_map, {'object_id': rel['object_id']})
      rid = rel['relationship_id']
      relationships.append(Relationship(rid, s, v, o, rel['synsets']))
    else:
      # Skip this relationship if we don't have the subject and object in 
      #   the object_map for this scene graph. Some data is missing in this way.
      count_skips[0] += 1
  if 'attributes' in data:
    for attr in data['attributes']:
      a = attr['attribute']
      if a['object_id'] in object_map:
        # the second argument should be an Object 
        attributes.append(Attribute(attr['attribute_id'], 
          Object(a['object_id'], a['x'], a['y'], a['w'], a['h'], a['names'], a['synsets']), a['attributes'], a['synsets']))
      else:
        count_skips[1] += 1
  if verbose:
    print 'Skipped {} rels, {} attrs total'.format(*count_skips)
  return Graph(image, objects, relationships, attributes)
示例#9
0
def ParseGraph(data, image):
    objects = []
    object_map = {}
    relationships = []
    attributes = []
    # Create the Objects
    for obj in data['bounding_boxes']:
        names = []
        synsets = []
        for s in obj['boxed_objects']:
            names.append(s['name'])
            synsets.append(ParseSynset(s['object_canon']))
            object_ = Object(obj['id'], obj['x'], obj['y'], obj['width'],
                             obj['height'], names, synsets)
            object_map[obj['id']] = object_
        objects.append(object_)
    # Create the Relationships
    for rel in data['relationships']:
        relationships.append(Relationship(rel['id'], object_map[rel['subject']], \
            rel['predicate'], object_map[rel['object']], ParseSynset(rel['relationship_canon'])))
    # Create the Attributes
    for atr in data['attributes']:
        attributes.append(Attribute(atr['id'], object_map[atr['subject']], \
            atr['attribute'], ParseSynset(atr['attribute_canon'])))
    return Graph(image, objects, relationships, attributes)
示例#10
0
    def __init__(self, user, response_format, instance, *args, **kwargs):

        super(ObjectLinksForm, self).__init__(*args, **kwargs)

        queryset = Object.filter_permitted(user, Object.objects)
        self.fields['links'].queryset = queryset

        if 'ajax' not in response_format:
            if instance:
                queryset = queryset.exclude(pk__in=instance.links.all())

            choices = []
            for obj in queryset:
                human_type = obj.get_human_type()
                name = do_truncate(
                    do_striptags(unicode(obj.object_name)), 20, True)
                if human_type:
                    name += u" (" + human_type + u")"
                choices.append((obj.id, name))
            self.fields['links'].choices = choices

        self.fields['links'].label = ""
        self.fields['links'].initial = ""
        self.fields['links'].widget.attrs.update({'class': 'autocomplete',
                                                  'callback': reverse('core_ajax_object_lookup')})
示例#11
0
def ParseGraphVRD(d):
    image = Image(d['photo_id'], d['filename'], d['width'], d['height'], '',
                  '')

    id2obj = {}
    objs = []
    rels = []
    atrs = []

    for i, o in enumerate(d['objects']):
        b = o['bbox']
        obj = Object(i, b['x'], b['y'], b['w'], b['h'], o['names'], [])
        id2obj[i] = obj
        objs.append(obj)

        for j, a in enumerate(o['attributes']):
            atrs.append(Attribute(j, obj, a['attribute'], []))

    for i, r in enumerate(d['relationships']):
        s = id2obj[r['objects'][0]]
        o = id2obj[r['objects'][1]]
        v = r['relationship']
        rels.append(Relationship(i, s, v, o, []))

    return Graph(image, objs, rels, atrs)
示例#12
0
def load_single(filepath, data):
    objects = data['objects']
    mtllib = data['mtllib']
    for mtl in mtllib:
        mtl.convert()
    model = Model(filepath)
    for obj in objects.itervalues():
        model.objects[obj.name] = Object(obj.name, obj.vdata, obj.material)
    return model
示例#13
0
    def __init__(self, user, location_id, *args, **kwargs):
        super(LocationForm, self).__init__(*args, **kwargs)

        self.fields['name'].label = _("Name")

        self.fields['parent'].label = _("Parent")
        self.fields['parent'].queryset = Object.filter_permitted(
            user, Location.objects, mode='x')
        if location_id:
            self.fields['parent'].initial = location_id
示例#14
0
def save_image_db(image_path: str):
    logger.info(f"Processing file {image_path}")
    filename = image_path.split(f"{os.sep}")[-1]
    mime = get_mime(filename.split(".")[1].lower())
    with open(image_path, "rb") as im:
        bin_data = im.read()
    classes = detect_objects(image_path)
    logger.info(f"Detected classes for {image_path}: {classes}")
    for cl in classes:
        Object(cl, bin_data, mime, path=image_path).save()
    os.remove(image_path)
示例#15
0
def newObject(request):
    title = "New Object"
    if request.method == 'POST': # If the form has been submitted...
        form = ObjectForm(request.POST) # A form bound to the POST data
        if form.is_valid(): # All validation rules pass
            country = form.cleaned_data['country']
            city = form.cleaned_data['city']
            zipcode = form.cleaned_data['zipcode']
            street = form.cleaned_data['street']
            housenumber = form.cleaned_data['housenumber']
            lon, lat = util.getLonLat(country, city, zipcode, street, housenumber)
            l = Location(
                        country = country,
                        city = city,
                        zipcode = zipcode,
                        street = street,
                        housenumber = housenumber,
                        longitude = lon,
                        latitude = lat
            )
            l.save()
            randID = ''.join(random.choice(string.ascii_lowercase + string.digits) for x in range(10))
            o = Object(
                        name = form.cleaned_data['name'],
                        description = form.cleaned_data['description'],
                        secretID = randID,
                        submissionDate = datetime.datetime.now(),
                        sender = request.user,
                        destination = l
            )
            o.save()
            return HttpResponseRedirect('/object/{0}'.format(o.id)) # Redirect after POST
        else:
            message = "The entered information wasn't valid. please check it."
            t = loader.get_template('main/newobject.html')
            ontext = util.generateContext(request, contextType = 'RequestContext', form=form, message=message, title=title)
            return HttpResponseServerError(t.render(context))
    else:
        form = ObjectForm() # An unbound form
    context = util.generateContext(request, contextType = 'RequestContext', form = form, title=title)
    return render_to_response('main/newobject.html', context)
示例#16
0
文件: views.py 项目: demvy/museum
def AddOnSpecInventorySave(request, id_number):
    try:
        project = Object.objects.get(id=int(id_number))
    except ObjectDoesNotExist:
        if id_number != '0':
            return HttpResponse('Об’єкт не існує.<br>Спробуйте інший id.')
        else:
            project = Object(name='Новий')
    if request.method == 'POST':
        form = SpecInventorySaveForm(request.POST)
        if form.is_valid():
            cd = form.cleaned_data
            act = Activity(time_stamp=dt.now(), aim = project, type='Спеціальний інвентарний облік', actor=Custom.myUser.objects.get(username=request.user.username))
            act.save()
            project.save()
            for (k, v) in cd.items():
                if k=='material':
                    v = unicode(v[1:-1].replace('u\'', '').replace('\'', ''))
                attr_assign = AttributeAssignment(attr_name=k, attr_value=v, attr_label=form.fields[k].label,
                                                  event_initiator=act, aim=project)
                attr_assign.save()
            return HttpResponseRedirect('/')
        else:
            return render(request, 'AddOnTs.html', {'form': form, 'errors': form.errors})
    else:

        ps_code = get_attrib_assigns('Приймання на постійне зберігання', project, 'PS_code')
        inventory_number = get_attrib_assigns('Інвентарний облік', project, 'inventory_number')
        mat_person_in_charge = get_attrib_assigns('Інвентарний облік' or 'Приймання на постійне зберігання', project, 'mat_person_in_charge')
        data = {'name': project.name, 'is_fragment': project.is_fragment, 'amount': project.amount,
                'author': project.author, 'date_creation': project.date_creation,
                'place_of_creation': project.place_of_creation,
                'size': project.size, 'description': project.description,
                'condition': project.condition, 'condition_descr': project.condition_descr,
                'recomm_for_restauration': project.recomm_for_restauration, 'note': project.note,
                'price': project.price, 'PS_code': ps_code, 'inventory_number': inventory_number,
                'link_on_doc': project.link_on_doc, 'mat_person_in_charge': mat_person_in_charge,
                'storage': project.storage}
        form = SpecInventorySaveForm(initial=data)
    return render(request, 'AddOnTs.html', {'form': form, 'label': 'Взяти об’єкт на спеціальний інвентарний облік'})
示例#17
0
def ajax_object_lookup(request, response_format='html'):
    "Returns a list of matching objects"

    objects = []
    if request.GET and 'term' in request.GET:
        objects = Object.filter_permitted(request.user.profile,
            Object.objects.filter(
                object_name__icontains=request.GET['term']),
            mode='x')[:10]

    return render_to_response('core/ajax_object_lookup',
                              {'objects': objects},
                              context_instance=RequestContext(request),
                              response_format=response_format)
示例#18
0
文件: views.py 项目: Lulzcritic/Time
 def post(self, request, *args, **kwargs):
     form_class = self.get_form_class()
     form = self.get_form(form_class)
     if form.is_valid():
         user = request.user
         character = Character(user=user, name=request.POST['name'], gender=request.POST['gender'])
         character.save()
         food = Object(obj_type=1)
         food.character = character
         food.save()
         bandage = Object(obj_type=2)
         bandage.character = character
         bandage.save()
         return HttpResponseRedirect('/')
         return self.form_valid(form, **kwargs)
     else:
         return self.form_invalid(form, **kwargs)
示例#19
0
class UserController:
    def __init__(self, mongo_name=None):
        self.mongo_wrapper = MongoWrapper(mongo_name)
        self.mono_db_names = self.mongo_wrapper.get_db_names()
        self.scenes_handler = Scene(self.mongo_wrapper)
        self.hypothesis_handler = Hypothesis(self.mongo_wrapper)
        self.objects_handler = Object(self.mongo_wrapper)
        self.active_data_type = self.scenes_handler

    def get_db_names(self):
        return self.mono_db_names

    def get_no_objs(self):
        no = self.mongo_wrapper.exist_persistent_obj()
        return no

    def set_active_db(self, db_name):
        self.mongo_wrapper = MongoWrapper(dbname=db_name)
        self.scenes_handler.set_mongo_wrp(self.mongo_wrapper)
        self.hypothesis_handler.set_mongo_wrp(self.mongo_wrapper)
        self.objects_handler.set_mongo_wrp(self.mongo_wrapper)

    def first_call(self, call_type, query=''):
        if call_type is "hypos":
            self.hypothesis_handler.reset()
            self.active_data_type = self.hypothesis_handler
            return self.hypothesis_handler.first_call(query)
        elif call_type is "scenes":
            self.scenes_handler.reset()
            self.active_data_type = self.scenes_handler
            return self.scenes_handler.first_call(query)
        elif call_type is "objects":
            self.objects_handler.reset()
            self.active_data_type = self.objects_handler
            return self.objects_handler.first_call()

    def prepare_export(self):
        self.active_data_type.prepare_export()
        return "OK"

    def get_timestamps(self):
        return self.mongo_wrapper.get_timestamps()

    def scroll_call(self, data_type):
        if data_type == "scenes_tab":
            return self.scenes_handler.scroll_call()
        elif data_type == "hypothesis_tab":
            return self.hypothesis_handler.scroll_call()
        elif data_type == "objects_tab":
            return self.objects_handler.scroll_call()
        return "OK"

    def export_all(self):
        return self.active_data_type.export_all()
示例#20
0
def parse_graph(data, image):
    """
    Helper to parse a Graph object from API data.
    """
    objects = []
    object_map = {}
    relationships = []
    attributes = []

    # Create the Objects
    for obj in data['bounding_boxes']:
        names = []
        synsets = []
        for bbx_obj in obj['boxed_objects']:
            names.append(bbx_obj['name'])
            synsets.append(parse_synset(bbx_obj['object_canon']))
            object_ = Object(obj['id'], obj['x'], obj['y'], obj['width'],
                             obj['height'], names, synsets)
            object_map[obj['id']] = object_
        objects.append(object_)
        pass

    # Create the Relationships
    for rel in data['relationships']:
        relationships.append(
            Relationship(rel['id'], object_map[rel['subject']],
                         rel['predicate'], object_map[rel['object']],
                         parse_synset(rel['relationship_canon'])))
        pass

    # Create the Attributes
    for atr in data['attributes']:
        attributes.append(
            Attribute(atr['id'], object_map[atr['subject']], atr['attribute'],
                      parse_synset(atr['attribute_canon'])))
        pass

    return Graph(image, objects, relationships, attributes)
示例#21
0
    db.session.add(dt)

for consumptionType in CONSUMPTIONTYPES:
    ct = ConsumptionType(name=consumptionType['name'], data_type_id=consumptionType['data_type_id'])
    db.session.add(ct)

for script in SCRIPTS:
    spt = Script(name=script['name'])
    db.session.add(spt)

for obj in OBJECTS:
    if 'script_id' in obj:
        spt_id = obj['script_id']
    else:
        spt_id = None
    o = Object(name=obj['name'], current_value=obj['current_value'], address=obj['address'],
               data_type_id=obj['data_type_id'], script_id=spt_id)

    db.session.add(o)

db.engine.execute('CREATE TABLE `event` ( \
        `id`	INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, \
        `object_id`	INTEGER NOT NULL, \
        `time`	TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\
        `value`	INTEGER \
);')  # Needs to be manual since we don't need it in the API

db.session.commit()

# Lets create all devices at the endpoint

item_endpoint = 'http://172.20.10.3:5000/api/v1/items'
示例#22
0
def main():
    """
    Function to launch and stop the program
    Inside we are 5 loops.
    1 = Program's loop
    2 = Home sreen loop
    3 = Game's loop
    4 = Winner's loop
    5 = Losing's loop
    """
    pygame.init()
    print(pygame)
    backpack = bp.Backpack(datas['structure'])
    maze = maz.Maze('data/maze.txt', datas['structure'])  # Map's iniatlization
    window = pygame.display.set_mode(
        (datas["nb_sprite"] * datas["width_sprite"],
         datas["nb_sprite"] * datas["width_sprite"]))
    icon = pygame.image.load(datas['img_icon'])
    pygame.display.set_icon(icon)
    pygame.display.set_caption(datas['title'])
    to_start = 1

    # Launch of the program
    while to_start:
        home = pygame.image.load(datas['img_home'])
        window.blit(home, (0, 0))  # Home screen display
        pygame.display.flip()  # Update the display
        choice = False
        home_loop = 1
        game_loop = 1

        # Launch of the Home Screen
        while home_loop:
            pygame.time.Clock().tick(30)
            for event in pygame.event.get():
                if event.type == QUIT or event.type == KEYDOWN and event.key == K_ESCAPE:
                    pygame.quit()
                    sys.exit()
                elif event.type == KEYDOWN:
                    if event.key == K_F1:
                        home_loop = 0
                        choice = True

        # If the gamer steps on the F1 key
        if choice:
            window = pygame.display.set_mode(
                ((datas["nb_sprite"] * datas["width_sprite"]) +
                 datas["width_bp"],
                 datas["nb_sprite"] * datas["width_sprite"]))
            # Read and display the maze and the backpack
            maze.read_maze()

            # Objects creation
            obj_syringe = obj.Object('syringe', datas['img_syringe'], maze,
                                     backpack)
            obj_ether = obj.Object('ether', datas['img_ether'], maze, backpack)
            obj_needle = obj.Object('needle', datas['img_needle'], maze,
                                    backpack)
            obj_plastic_tube = obj.Object('plastic tube',
                                          datas['img_plastic_tube'], maze,
                                          backpack)

            # Main character creation
            mc_gyver = char.Character(datas['img_mcgyver'], maze)

            # Random position objects
            obj_ether.random_position()
            obj_needle.random_position()
            obj_plastic_tube.random_position()

            maze.view_maze(window)
            backpack.view_backpack(window)

        you_win = 0
        you_loose = 0
        # Launch of the game
        while game_loop:
            pygame.time.Clock().tick(30)

            # User's events
            for event in pygame.event.get():
                if event.type == QUIT:
                    game_loop = 0
                    pygame.quit()
                    sys.exit()
                elif event.type == KEYDOWN:
                    if event.key == K_ESCAPE:
                        game_loop = 0
                    elif event.key == K_RIGHT:
                        mc_gyver.move('right', window)
                    elif event.key == K_LEFT:
                        mc_gyver.move('left', window)
                    elif event.key == K_UP:
                        mc_gyver.move('up', window)
                    elif event.key == K_DOWN:
                        mc_gyver.move('down', window)
                else:
                    pass

            window.blit(mc_gyver.name, (mc_gyver.map_x, mc_gyver.map_y))

            # If the character get an object
            mc_gyver.get_an_object(obj_ether, window)
            mc_gyver.get_an_object(obj_needle, window)
            mc_gyver.get_an_object(obj_plastic_tube, window)

            # View objects
            obj_ether.view_object(window)
            obj_needle.view_object(window)
            obj_plastic_tube.view_object(window)

            # Method's Character
            mc_gyver.create_syringe(window, obj_syringe)

            if obj_syringe.syringe:
                obj_ether.remove_object(window)
                obj_needle.remove_object(window)
                obj_plastic_tube.remove_object(window)

            mc_gyver.asleep(window)
            pygame.display.flip()

            # -------------------- FINISH GAME -----------------------------
            # If the character escapted or not
            if mc_gyver.state is False:
                game_loop = 0
                you_win = 1
            elif maze.maze_structure[mc_gyver.position_x][
                    mc_gyver.position_y] == 'F':
                if mc_gyver.state:
                    game_loop = 0
                    you_loose = 1

        # Launch of the win screen
        while you_win:
            window = pygame.display.set_mode(
                (datas["nb_sprite"] * datas["width_sprite"],
                 datas["nb_sprite"] * datas["width_sprite"]))

            for event in pygame.event.get():
                if event.type == QUIT:
                    you_win = 0
                    pygame.quit()
                    sys.exit()
                elif event.type == KEYDOWN:
                    if event.key == K_ESCAPE:
                        you_win = 0

            win = pygame.image.load(datas['img_win'])
            window.blit(win, (0, 0))
            pygame.display.flip()

        # Launch of the loose screen
        while you_loose:
            window = pygame.display.set_mode(
                (datas["nb_sprite"] * datas["width_sprite"],
                 datas["nb_sprite"] * datas["width_sprite"]))
            loose = pygame.image.load(datas['img_loose'])
            window.blit(loose, (0, 0))
            pygame.display.flip()

            for event in pygame.event.get():
                if event.type == QUIT:
                    you_loose = 0
                    pygame.quit()
                    sys.exit()
                elif event.type == KEYDOWN:
                    if event.key == K_ESCAPE:
                        you_loose = 0