import os

from cfg import Config
Config = Config()

from about import STAGE
from about import VERSION
from about import REVISION

#Small function which clears the screen in the console.
#This function is ONLY used for debugging in the console, and is
#never used when the program is opened with the GUI.
def clr():
    if True:
        os.system("CLS")
    else:
        for i in range(0, 25):
            print ""

#This function stops the console window to allow the operator to read.
#Like the clr function, this is ONLY used for debugging in the console.
def cont():
    raw_input("Press enter to continue...")

def findSS(line, first, last):
    try:
        start = line.index(first) + len(first)
        end = line.index(last, start)
        return line[start:end]
    except ValueError:
        return ""

def validateBarcode(barcode):
    try:
        barcode = int(barcode)
    except ValueError:
        return False
    if len(str(barcode)) is not 14:
        return False
    else:
        return True

def checkarrel(arr, index):
    try:
        arr[index]
    except IndexError:
        return False
    return True

def checkForAlpha(string):
    for letter in string:
        if not letter.isalpha():
            return False
    return True

def validateName(string):
    for letter in string:
        if not letter.isalpha():
            if letter in Config.allowedNameChars:
                pass
            else:
                return [False, letter]
    return [True]

def validateMuni(string):
    for letter in string:
        if not letter.isalpha():
            if letter in Config.allowedMuniChars:
                pass
            else:
                return [False, letter]
    return [True]

def parseDate(date):
    date = date.split("-")
    if len(date) is not 3:
        return False
    else:
        month = str(int(date[0]))
        day = date[1]
        year = date[2]
        if 0 >= int(month) <= 13:
            return False
        if 0 >= int(day) <= 32:
            return False
        res = month + "-" + day + "-" + year
        return res
        

def genReadMe():
    ver = "B " + VERSION
    if REVISION is not "0":
        ver += " R" + REVISION
    rm = "Digitial Visitor Card Log Ver " + ver + "\n"
    
    rm += """

"Better than SAM!" - Some Guy

#############################
#        BASIC INFO         #
#############################

This program was designed and written by Tyler Vitale, for the
Northville District Library. The purpose of the program is to expedite
the visitor card issuing process by allowing computer pages to access
information all in one place. Using this program, you can quickly and easily
find out how many visitor cards a patron has obtained as well as viewing other
important pieces of information about a patron.

It should be noted however, that this is a manual program.
This means that the program has absolutely no outside access to any additional
information other than what is in its own database.

For the library's purposes:
- It has no access to Workflows.
- It has no access to SAM.
- It has no access to any of the excel files.
- It has no access to anything else for that matter.

If a patron is blocked in the program, that means someone had to have set their
status that way. If a patron has information written on their account or their
name is spelled wrong or something, then the only way that can 

#############################
#       INSTALLATION        #
#############################

1. Ensure you have Python 2.7.x installed. The program was written using
Python 2.7.10, so that would be the best version to use. Python can be found at
https://www.python.org/downloads/

2. Next, create a folder to put the program in. The exact location of the
folder is not important. Copy and past the program's files into this folder.

3. Within this folder you've just created should now be a series of files
and folders. One of these folders should be the admintools folder. Open it up.

4. Within the admintools folder, you should see a few python scripts.
First, execute the script entitled "createdb.py"
This script will create a database file for the program to use.

5. Next, run the script entitled "makenewpw.py"
This script will prompt you for a password which you need to type in to the
command line. BEAR IN MIND: the program will NOT HIDE YOUR PASSWORD.
Make sure you do this in private.

6. Next, you should see that these scripts have created two files: "data.db"
and "auth.pyc"
Cut and paste these files into the src folder in the folder above the
admintools folder.

7. Installation should now be done. Run the program by running either
main.py or main.pyw. I recommend running the program with main.py (debugger)
so that if any errors come up, you can see them. You can then enter the
password you set during the execution of makenewpy.py.

    """
    readme = open("README.txt", 'w')
    readme.write(rm)
    readme.close()

genReadMe()
