import os
import csv
import datetime

now = datetime.datetime.now()


def parseing(fileName):
    debugCounter = 0
    sectionTemplate = """
:doc:`{subject}{catNumber}`{SpTopic} {Term}
    | Section {section} ({classNumber}) Credits: {units}; {mixture}; {component}
    | Instructor: {Instructor}
    |{Building}:{Room} {Location} {Days} {Time}

	{description}
"""

    sectionTemplateMultiRoom = """
:doc:`{subject}{catNumber}`{SpTopic} {Term}
    | Section {section} ({classNumber}) Credits: {units}; {mixture}; {component}
    | Instructor: {Instructor}
    {multiRoom}

	{description}
"""

    sectionTemplateLab = """
:doc:`{subject}{catNumber}`{SpTopic} {Term}
    | Section {section}/{labSection} ({classNumber}) Credits: {units}; {mixture}; {component}
    | Instructor: {Instructor}
    |{Building}:{Room} {Location} {Days} {Time}
    |{labBuilding}: {labRoom} ({labLocation}) {labDay} {labTime} (lab)

	{description}
"""

    comp314_315Template = """
	{subject}{catNumber} {Term} (Description: :doc:`comp314-315`)
		| Section {section} ({classNumber}) Credits: {units}; {mixture}; {component}
		| Instructor: {Instructor}
	        |{Building}:{Room} {Location} {Days} {Time}

	{description}
	"""

    topicsSectionTemplate = """
{subject}{catNumber} Topic{topics} {Term}
	| Section {section} ({classNumber}) Credits: {units}; {mixture}; {component}
	| Instructor: {Instructor}
	|{Building}:{Room} {Location} {Days} {Time}
	| Description similar to: :doc:`{docName}`

{description}
"""

    headerTemplate = """
{semester} Schedule {txtURLline} {where}
==========================================================================
{created}

The following courses will (tentatively) be held during the {semester} semester.

For open/full status and latest changes, see
`LOCUS <http://www.luc.edu/locus>`_.

**In case of conflict, information on LOCUS should be considered authoritative.**

See `Textbook Information {textBookURLline}`_.

Section titles lines link to the course description page,
except for some labeled special topics courses related to an existing course.

The 4-digit number in parentheses after the section is the LOCUS registration code.

Be sure to look at the section's notes or LOCUS for an 8-week courses with more than one schedule line:
Friday line(s) are likely to be isolated makeup days, not every week.

{graduateLink}

**View Campus Specific Courses below :**{pages}



.. _{season}_undergraduate_courses_list:

{udergradeTxt}
~~~~~~~~~~~~~~~~~~~~~

"""

    gradHeadingTemplate = """

.. _{0}_graduate_courses_list_{1}:

Graduate Courses
~~~~~~~~~~~~~~~~~~~~~

"""

    indepStudyTemplate = """
:doc:`{}` 1-6 credits
	You cannot register
	yourself for an independenst study course!
	You must find a faculty member who
	agrees to supervisor the work that you outline and schedule together.  This
	*supervisor arranges to get you registered*.  Possible supervisors are: full-time department faculty
	"""
    classes = []
    headerObject = {
        "semester": "",
        "textBookURLline": "<https://docs.google.com/spreadsheets/d/138_JN8WEP8Pv5uqFiPEO_Ftp0mzesnEF5IFU1685w3I/edit?usp=sharing>",
        "created": "",
        "graduateLink": "",
        "campusURLTemplateCuneo": "",
        "season": "",
        "udergradeTxt": "Undergraduate Courses",
        "where": "",
        "pages": "",
        "txtURLline": "",