import ast
import os
providers = {}
def addprovider(codeprovider, name, agent, phonecompany, phoneagent):
providers[codeprovider] = {
'name': name,
'agent': agent,
'phonecompany': phonecompany,
'phoneagent': phoneagent
}
with open('providers.txt', 'w') as f:
f.write(str(providers))
def readproviders():
if not os.path.isfile('providers.txt'):
return
with open('providers.txt', 'r') as f:
return ast.literal_eval(f.read())
def askproviders():
codeprovider = input('Enter the code of the provider')
name = input('Enter the name of the provider')
agent = input('Enter the name of the agent')
phonecompany = input('Enter the number of the company')
phoneagent = input('Enter the number of the agent')
addprovider(codeprovider,
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import ast
def main():
if os.stat("data.txt").st_size == 0:
archivo = open("data.txt","w")
archivo.close()
archivo = open("data.txt","r")
archivo_leido = archivo.read()
lista = ast.literal_eval(archivo_leido)
while True:
print("1. Ingresar provedores")
print("2. Leer")
print("3. Salir")
opcion = input("")
if opcion == "1":
codigo = input("Ingrese codigo: ")
nombre_empresa = input("Ingrese nombre de la empresa: ")
nombre_agente = input("Ingrese nombre del agente: ")
telefono_empresa = input("
def menu():
print("1. Clientes")
print("2. Proveedores")
print("3. Stock")
print("4. Factura")
print("5. Salir")
opcion=input()
while opcion not in ['1', '2', '3', '4', '5']:
print("\nIntroduce una opcion valida: ")
opcion=input()
if opcion=='1':
clientes()
elif opcion=='2':
proveedores()
elif opcion=='3':
stock()
elif opcion=='4':
factura()
elif opcion=='5':
exit()
def menu_general():
opcion = 0
while opcion != 5:
print("""
menu general
1. Clientes
2. Proveedores
3. Stock
4. Factura
5. Salir
""")
opcion = int(input("ingrese la opcion deseada: "))
if opcion == 1:
print("ingresando al modulo clientes...")
elif opcion == 2:
print("ingresando al modulo proveedores...")
elif opcion == 3:
print("ingresando al modulo stock...")
elif opcion == 4:
print("ingresando al modulo factura...")
elif opcion == 5:
print("saliendo del programa...")
else:
print("ingrese una opcion correcta...")
menu_general()
def client_add():
nombre = input("ingresa tu nombre")
codigo = input("ingresa tu codigo")
direccion = input("ingresa tu direccion")
telefono = input("ingresa tu telefono")
gmail = input("ingresa tu gmail")
client_data = {
"nombre":nombre,
"codigo":codigo,
"direccion":direccion,
"telefono": telefono,
"gmail":gmail
}
return client_data
def menu(opciones):
print('*****************************')
print('*** Bienvenido a nuestro menu ***')
print('*****************************')
for opc in opciones:
print(opc)
print('Escribe tu opcion: ')
opcion = input()
return opcion
def add(a, b):
return a + b
add(1, 2)
import os
import ast
def ingresar_datos():
code_provedor = input("Ingrese el codigo del provedor: ")
company_name = input("Ingrese el nombre de la empresa: ")
agent_name = input("Ingrese el nombre del agente: ")
company_phone = input("Ingrese el telefono de la empresa: ")
agent_phone = input("Ingrese el telefono del agente: ")
return code_provedor, company_name, agent_name, company_phone, agent_phone
def guardar_datos(datos):
if not os.path.exists("proveedores.txt"):
open("proveedores.txt", "w").close()
with open("proveedores.txt", "r") as f:
data = f.read()
if data == "":
lista_proveedores = []
else:
def nuevo_cliente():
codigo = input('ingrese el codigo del cliente')
nombre = input('ingrese el nombre del cliente')
direccion = input('ingrese la direccion del cliente')
telefono = input('ingrese el telefono del cliente')
gmail = input('ingrese el gmail del cliente')
lista = [codigo, nombre, direccion, telefono, gmail]
print('el cliente ha sido ingresado')
return lista
import os
def menu():
print('1. nuevo cliente')
print('2. salir')
opcion = input('opcion')
if opcion == 1:
nuevo_cliente()
with open('clientes.txt', 'a') as f:
f.write(str(nuevo_cliente()) + '\n')
menu()
elif opc
def menu():
while True:
try:
print("""
Menu
[1] Ingresar datos de una nueva persona
[2] Mostrar datos de una persona
[3] Salir
""")
opcion = int(input("Ingresa una opcion: "))
if opcion == 1:
ingresar_datos()
elif opcion == 2:
mostrar_datos()
elif opcion == 3:
break
else:
print("Ingresa una opción válida")
except ValueError:
print("Ingresa una opción válida")
def ingresar_datos():
while True:
try:
codigo = int(input("Ingresa el código del cliente: "))
if codigo < 0:
print("Ingresa un código válido")
continue
else:
break
def new_client():
name = input("ingrese el nombre del cliente")
code = input("ingrese el codigo del cliente")
telephone = input("ingrese el telefono")
email = input("ingrese el email")
address = input("ingrese la direccion")
return f"{code},{name},{telephone},{email},{address}\n"
def menu():
print("""
1. Clientes
2. Provedores
3. Stock
4. Factura
""")
opcion = int(input("Seleccione el archivo que quiere trabajar: "))
if opcion == 1:
import clientes
elif opcion == 2:
import provedores
elif opcion == 3:
import stock
elif opcion == 4:
import factura
else:
print("Opcion no valida, intente de nuevo")
menu()
menu()
import ast
import os
usuario = []
def menu():
print("""
1. ingresar clientes
2. listar clientes
3. salir
""")
opcion = input("Ingrese una opcion: ")
return opcion
def ingresar():
codigo = input("Ingrese el codigo del cliente: ")
nombre = input("Ingrese el nombre del cliente: ")
direccion = input("Ingrese la direccion del cliente: ")
telefono = input("Ingrese el telefono del cliente: ")
gmail = input("Ingrese el gmail del cliente: ")
usuario.append(codigo)
usuario.append(nombre)
usuario.append(direccion)
usuario.append(telefono)
usuario.append(gmail)
respuesta = input("D
import os
nombre = input("Ingrese el nombre del cliente: ")
codigo = input("Ingrese el codigo del cliente: ")
direccion = input("Ingrese la direccion del cliente: ")
telefono = input("Ingrese el telefono del cliente: ")
gmail = input("Ingrese el gmail del cliente: ")
os.system("echo '" + nombre + "' >> cliente.txt")
os.system("echo '" + codigo + "' >> cliente.txt")
os.system("echo '" + direccion + "' >> cliente.txt")
os.system("echo '" + telefono + "' >> cliente.txt")
os.system("echo '" + gmail + "' >> cliente.txt")
def menu():
# clear screen
os.system('cls')
print("***********************************************")
print("* Bienvenido al sistema de control del negocio *")
print("***********************************************")
print("1. Clientes")
print("2. Proveedores")
print("3. Stock")
print("4. Factura")
print("\n9. Salir")
option = input("\nIngrese una opcion: ")
return int(option)
# ingresar usando input nombre del cliente, codigo del cliente, direcion, telefono, gmail , guardar y leer los datos en un archivo txt usando os y ast
import os
import ast
def get_data(name, code, address, phone, email, list_new_data):
new_data = {"name": name,
"code": code,
"address": address,
"phone": phone,
"email": email}
list_new_data.append(new_data)
return list_new_data
def write_file(list_new_data):
file = open("data.txt", "w")
file.write(str(list_new_data))
file.close()
def read_file(list_new_data):
file_read = open("data.txt", "r")
data = file_read.read()
file_read.close()
data = ast.literal_eval(data)
def menu():
print('1. Ingresar Clientes')
print('2. Ingresar Provedores')
print('3. Ingresar Stock')
print('4. Ingresar Factura')
print('5. Salir')
opcion =int(input('Escoja una opcion: '))
def menu():
print('Bienvenido al sistema de gestion de una empresa')
print('1. Clientes')
print('2. Proveedores')
print('3. Stock')
print('4. Factura')
print('5. Salir')
opc = int(input('Cual es su eleccion? '))
if opc == 1:
import clientes
elif opc == 2:
import proveedores
elif opc == 3:
import stock
elif opc == 4:
import factura
elif opc == 5:
print('Gracias por usar el sistema!')
sys.exit(0)
else:
print('Solo se permite las opciones indicadas')
menu()
menu()
def menu():
print("menu de opciones")
print("1. Ingresar datos")
print("2. Guardar datos")
print("3. Salir")
return int(input("Ingrese una opcion >"))
def ingreso_datos():
print("ingreso de datos")
cliente = input("Ingrese el codigo del cliente: ")
nombre = input("Ingrese el nombre del cliente: ")
direccion = input("Ingrese la direccion del cliente: ")
telefono = input("Ingrese el telefono del cliente: ")
gmail = input("Ingrese el gmail del cliente: ")
return [cliente, nombre, direccion, telefono, gmail]
def guardar_datos(datos):
with open("clientes.txt", "a") as archivo:
for dato in datos:
def Menu():
print(" Menu \n 1: Ingresar datos \n 2: Ver Datos \n 3: Salir")
def Ingresar():
codigo = input("Ingrese codigo de cliente: ")
nombre = input("Ingrese nombre: ")
direccion = input("Ingrese direccion: ")
telefono = input("Ingrese telefono: ")
gmail = input("Ingrese gmail: ")
datos = [codigo, nombre, direccion, telefono, gmail]
return datos
def Ver(DATOS):
print("El codigo de cliente: "+ DATOS[0])
print("El nombre: "+ DATOS[1])
print("La direccion: "+ DATOS[2])
print("El telefono: "+ DATOS[3])
print("El gmail: "+ DATOS[4])
import os
import ast
def menu():
print("""
1. Tabla de Clientes
2. Agregar Clientes
3. Salir
""")
opcion = int(input("Seleccione una opcion: "))
return opcion
def agregar():
lista = []
codigo = input("Codigo: ")
name = input("Nombre: ")
direccion = input("Direccion: ")
telefono = input("Telefono: ")
gmail = input("Gmail: ")
lista.append(codigo)
lista.append(name)
lista.append(direccion)
lista.append(telefono)
lista.append(gmail)
return lista
def agregarArchivo():
archivo= open("clientes.txt","a")
archivo.write(str(agregar()))
archivo.write("
import os
import ast
def save_and_read(data):
os.chdir('C:\\Users\\dell\\Desktop')
with open('agentes.txt', 'a+') as file:
file.write(str(data))
file.close()
with open('agentes.txt', 'r') as file:
data = file.read()
file.close()
data = ast.literal_eval(data)
return data
# ingresar usando input un codigo de provedores, nombre de la empresa, nombre del agente, telefono de la empresa, telefono agente
codigo_provedor = input("Digite el codigo del provedor: ")
nombre_empresa = input("Digite el nombre de la empresa: ")
nombre_agente = input("Digite el nombre del agente: ")
telefono_empresa = input("Digite el telefono de la empresa: "
import os
import ast
#crear lista donde el usuario ingrese, el codigo de cliente, un nombre, direccion, telefono, gmail
def add():
listinfo = []
listinfo.append(input("Ingresa codigo de cliente: "))
listinfo.append(input("Ingresa el nombre: "))
listinfo.append(input("Ingresa la dirección: "))
listinfo.append(input("Ingresa el telefono: "))
listinfo.append(input("Ingresa el gmail: "))
return listinfo
#crear menu para que el usuario quiera o no ingresar los datos
def menu():
print("\nSelecciona una opción\n1. Add\n2. Read\n3. Salir\n")
opcion = input()
if opcion == '1':
add()
elif opcion == '2':
read()
el
import os
import ast
list_clientes = []
cliente = {}
def menu():
print('\nIngrese "1" para agregar clientes: ')
print('Ingrese "2" para ver la lista de clientes: ')
print('Ingrese "3" para ver el directorio: ')
print('Ingrese "4" para ver el contenido dentro del directorio: ')
print('Ingrese "5" para ver el contenido dentro de un archivo de texto: ')
print('Ingrese "0" para salir: ')
return int(input('\nQue desea hacer? '))
def agregar_clientes():
cliente['codigo'] = input('\nIngrese el codigo del cliente: ')
cliente['nombre'] = input('Ingrese el nombre del cliente: ')
cliente['direccion'] = input('Ingrese la direccion del
import os
import ast
def create_file(filename):
if os.path.exists(filename):
return False
else:
return True
def save_client(client):
with open(filename, 'a') as file:
file.write(client)
def get_file_lines(filename):
return len(open(filename).readlines())
def read_file(filename):
with open(filename, 'r') as file:
for line in file:
print(line)
def read_file_json(filename):
with open(filename, 'r') as file:
for line in file:
print(ast.literal_eval(line))
def update_file(filename):
with open(filename, 'a') as file:
file.write(client)
def delete_file(filename):
if os.path.exists(filename):
os.remove(filename)
return True
else:
return False
def write_client(filename
nombre_proveedor = input("Ingrese el nombre del proveedor: ")
telefono_proveedor = input("Ingrese el telefono del proveedor: ")
nombre_agente = input("Ingrese el nombre del agente: ")
telefono_agente = input("Ingrese el telefono del agente: ")
def menu():
print('1. Clientes')
print('2. Provedores')
print('3. Stock')
print('4. Factura')
opcion = int(input('Digite una opcion: '))
return opcion
menu()
def menu():
print("1) Clientes")
print("2) Provedores")
print("3) Stock")
print("4) Factura")
print("")
print("0) Salir")
print("")
return int(input("Elija una opcion: "))