Skip to content

Commit

Permalink
Mega refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
vdumoulin committed Oct 8, 2015
1 parent 592e3e5 commit 26e3102
Show file tree
Hide file tree
Showing 9 changed files with 703 additions and 1,133 deletions.
19 changes: 6 additions & 13 deletions cli.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
# -*- coding: utf-8 -*-
"""
Command-line interface for the register
"""
__authors__ = "Vincent Dumoulin"
__copyright__ = "Copyright 2014, Vincent Dumoulin"
__credits__ = ["Vincent Dumoulin"]
__license__ = "GPL v2"
__maintainer__ = "Vincent Dumoulin"
__email__ = "vincent.dumoulin@umontreal.ca"
"""Command-line interface for the register."""

import argparse
from pyplanck.register import Register
from pyplanck.exceptions import CredentialException, ItemNotFoundException

from .register import Register
from .exceptions import CredentialException, ItemNotFoundException


class CLI(object):
Expand All @@ -21,7 +14,7 @@ def quit(self):
def login(self, token):
try:
self.register.login_employee(token)
self.prompt = self.register.get_employee_name() + " > "
self.prompt = self.register.employee_name + " > "
except CredentialException:
self.logger.warning("invalid employee token '" + token + "', " +
"unable to login")
Expand Down Expand Up @@ -102,7 +95,7 @@ def count(self, count_string):

def __init__(self, register, default_prompt="caisse-planck > "):
self.register = register
self.logger = register.get_events_logger()
self.logger = register.events_logger
self.default_prompt = default_prompt
self.prompt = self.default_prompt
self.end = False
Expand Down
71 changes: 0 additions & 71 deletions employee.py

This file was deleted.

10 changes: 1 addition & 9 deletions exceptions.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
# -*- coding: utf-8 -*-
"""
Exception-related classes
"""
__authors__ = "Vincent Dumoulin"
__copyright__ = "Copyright 2014, Vincent Dumoulin"
__credits__ = ["Vincent Dumoulin"]
__license__ = "GPL v2"
__maintainer__ = "Vincent Dumoulin"
__email__ = "vincent.dumoulin@umontreal.ca"
"""Exception-related classes."""


class CredentialException(Exception):
Expand Down
29 changes: 29 additions & 0 deletions immutables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
"""Immutable objects."""
from collections import namedtuple

from .utils import (validate_name, validate_employee_level, validate_amount,
validate_item_shortcut)


Employee = namedtuple(
'Employee', 'name barcode code level', verbose=False)

Item = namedtuple(
'Item', 'name price barcode category shortcut', verbose=False)
Item.__new__.__defaults__ = ('General', None)


def validate_employee(name, barcode, code, level):
validate_name(name, 'employee name')
validate_name(barcode, 'employee barcode')
validate_name(code, 'employee code')
validate_employee_level(level)


def validate_item(name, price, barcode, category, shortcut):
validate_name(name, 'item name')
validate_amount(price, 'item price')
validate_name(barcode, 'item barcode')
validate_name(category, 'item category')
validate_item_shortcut(shortcut)
85 changes: 0 additions & 85 deletions item.py

This file was deleted.

Loading

0 comments on commit 26e3102

Please sign in to comment.