asistencias.py

Open
#56 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
Under an hour
Newbie friendliness
15/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Active
Tech stack
python
Domain
cli

Research direction

The pasted file is a Python attendance-control script, not code from this JavaScript/TypeScript repository, and the issue does not say what to change. The visible defects are a stray backtick in registrar_empleado (printi/n¨...), a backtick before from datetime import datetime at the top, and the label sALIDA in mostrar_registro. Confirm with the author what is wanted before editing, then run the script with python asistencias.py to check that it starts.

Written by the indexing model from the issue text.

Description

from datetime import datetime

===================== CLASE EMPLEADO =====================

class Empleado:
def init(self, numero, nombre, puesto):
self.numero = numero
self.nombre = nombre
self.puesto = puesto
self.entrada = None
self.salida = None

def registrar_entrada(self):
    if self.entrada is None:
        self.entrada = datetime.now()
        print(f"\nEntrada registrada para: {self.nombre}")
        print(f"Hora: {self.entrada.strftime('%d/%m/%Y %H:%M:%S')}")
    else:
        print(f"\n {self.nombre} ya tiene una entrada registrada.")

def registrar_salida(self):
    if self.entrada is None:
        print(f"\n {self.nombre} no tiene entrada registrada.")
    elif self.salida is None:
        self.salida = datetime.now()
        print(f"\nSalida registrada para: {self.nombre}")
        print(f"🕐 Hora: {self.salida.strftime('%d/%m/%Y %H:%M:%S')}")
    else:
        print(f"\n {self.nombre} ya tiene una salida registrada.")

def mostrar_registro(self):
    print("\n" + "-" * 40)
    print(f"NÚMERO:  {self.numero}")
    print(f"NOMBRE:  {self.nombre}")
    print(f"PUESTO:  {self.puesto}")
    
    if self.entrada:
        print(f"ENTRADA: {self.entrada.strftime('%d/%m/%Y %H:%M:%S')}")
    else:
        print(f"ENTRADA: Sin registro")
    
    if self.salida:
        print(f"SALIDA:  {self.salida.strftime('%d/%m/%Y %H:%M:%S')}")
    else:
        print(f"sALIDA:  Sin registro")
    print("-" * 40)

===================== CLASE CONTROL DE ASISTENCIA =====================

class ControlAsistencia:
def init(self):
self.empleados = {}

def registrar_empleado(self):
    print("\n" + "=" * 40)
    print("       REGISTRAR EMPLEADO")
    print("=" * 40)
    
    numero = input("Número de empleado: ")
    
    if numero in self.empleados:
        `printi/n¨El empleado ya está registrado.")
        return
    
    nombre = input("👤 Nombre completo: ")
    puesto = input("💼 Puesto: ")
    
    self.empleados[numero] = Empleado(numero, nombre, puesto)
    print("✅ Empleado registrado correctamente.")

def buscar_empleado(self):
    print("\n" + "=" * 40)
    numero = input("🔢 Número de empleado: ")
    if numero in self.empleados:
        return self.empleados[numero]
    print("❌ Empleado no encontrado.")
    return None

def registrar_entrada(self):
    print("\n" + "=" * 40)
    print("       REGISTRAR ENTRADA")
    print("=" * 40)
    empleado = self.buscar_empleado()
    if empleado:
        empleado.registrar_entrada()

def registrar_salida(self):
    print("\n" + "=" * 40)
    print("        REGISTRAR SALIDA")
    print("=" * 40)
    empleado = self.buscar_empleado()
    if empleado:
        empleado.registrar_salida()

def mostrar_registros(self):
    print("\n" + "=" * 40)
    print("      LISTA DE REGISTROS")
    print("=" * 40)
    
    if not self.empleados:
        print("📭 No hay empleados registrados.")
        return
    
    for empleado in self.empleados.values():
        empleado.mostrar_registro()

===================== PROGRAMA PRINCIPAL =====================

def main():
sistema = ControlAsistencia()

while True:
    print("\n" + "=" * 40)
    print("    SISTEMA DE CONTROL DE ASISTENCIA")
    print("=" * 40)
    print(" 1 → Registrar empleado")
    print(" 2 → Registrar entrada")
    print(" 3 → Registrar salida")
    print(" 4 → Mostrar todos los registros")
    print(" 5 → Salir del sistema")
    print("=" * 40)
    
    opcion = input("👉 Elige una opción: ")
    
    if opcion == "1":
        sistema.registrar_empleado()
    elif opcion == "2":
        sistema.registrar_entrada()
    elif opcion == "3":
        sistema.registrar_salida()
    elif opcion == "4":
        sistema.mostrar_registros()
    elif opcion == "5":
        print("\n👋 Sistema finalizado. ¡Hasta luego!")
        break
    else:
        print("\n❌ Opción no válida. Intenta nuevamente.")

Ejecutar el programa

if name == "main":
main()

Dominant language
TypeScript
Stars
104
Forks
36
Avg merge
4d 23h
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from serpapi/serpapi-javascript

All issues in serpapi/serpapi-javascript

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.