Skip to content

Commit

Permalink
Cleaned up code
Browse files Browse the repository at this point in the history
Thats it folks.

Co-authored-by: Joberth Rogers <[email protected]>
Co-authored-by: Daniel Maike <[email protected]>
  • Loading branch information
3 people committed Jun 24, 2019
1 parent 57c6982 commit 7b9782c
Show file tree
Hide file tree
Showing 15 changed files with 11 additions and 79 deletions.
2 changes: 0 additions & 2 deletions databaseConfig/SaveData.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from databaseConfig.habilitationDatabase import HabilitationDb
from databaseConfig.dbConnection import Database

from multiprocessing.pool import ThreadPool


class SaveData:
# This is only a class intermediate between extraction part
Expand Down
1 change: 0 additions & 1 deletion databaseConfig/disciplineDatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def saveDiscipline(disciplines):
dict_disciplines[discipline.getCode()].setClasses(old_classes + discipline.getClasses())
else:
dict_disciplines[discipline.getCode()] = discipline


progress, total = 0, len(dict_disciplines) - 1
for discipline in dict_disciplines:
Expand Down
1 change: 1 addition & 0 deletions databaseConfig/habilitationDatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


class HabilitationDb(Database):

# Class static to save all data related to
# Habilitation in Courses
@staticmethod
Expand Down
12 changes: 1 addition & 11 deletions mwscanner.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import sys

from multiprocessing.pool import ThreadPool

from mwscanner.builders.CampusBuilder import CampusBuilder
from mwscanner.Campus import Campus
from mwscanner.Discipline import Discipline
from databaseConfig.SaveData import SaveData


Expand All @@ -15,11 +12,6 @@ def proccessHabilitations(campus: Campus):

all_habilitations = []

t_pool = ThreadPool(processes=8)
async_tasks = []

courses_len = len(campus.getCourses())

for index, course in enumerate(campus.getCourses()):

for habilitation in course.getHabilitations():
Expand All @@ -30,9 +22,8 @@ def proccessHabilitations(campus: Campus):


def proccessDisciplines(campus: Campus):
all_disciplines = []

departments_len = len(campus.getDepartments())
all_disciplines = []

# prints department information
# and then build the list of disciplines that each department have
Expand Down Expand Up @@ -76,7 +67,6 @@ def proccessDisciplines(campus: Campus):

t_pool.terminate()


print("Calling db save function...")

SaveData.saveData(
Expand Down
2 changes: 1 addition & 1 deletion mwscanner/Campus.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Campus():
class Campus:
# This class represent all the 4 campus prensent in UnB

# Define the attributes basics from all campus
Expand Down
2 changes: 1 addition & 1 deletion mwscanner/Class.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Class():
class Class:
# This class represents a discipline class on Matricula
# Web. It contains data about the meetings and a
# connection to the discipline.
Expand Down
17 changes: 1 addition & 16 deletions mwscanner/Course.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
import re
import sys

import requests
from bs4 import BeautifulSoup
from requests import get

from mwscanner.Habilitation import Habilitation
from mwscanner.builders.HabilitationBuilder import HabilitationBuilder
from mwscanner.Mixins import UrlLoaderMixin


from mwscanner import BASE_URL


class Course(UrlLoaderMixin):
class Course:
# This class represents a course registered on the Matricula
# Web. It has the information about this course.

Expand Down
14 changes: 1 addition & 13 deletions mwscanner/Department.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
import sys

import requests
from bs4 import BeautifulSoup
from requests import get

from mwscanner import BASE_URL
from mwscanner.Discipline import Discipline
from mwscanner.builders.DisciplinesBuilder import DisciplinesBuilder
from mwscanner.Mixins import TableReaderMixin, UrlLoaderMixin


class Department(TableReaderMixin, UrlLoaderMixin):
class Department:

def __init__(self):
# department attributes
Expand Down
13 changes: 1 addition & 12 deletions mwscanner/Discipline.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
import sys

import requests
from bs4 import BeautifulSoup
from requests import get

from mwscanner import BASE_URL
from mwscanner.Mixins import TableReaderMixin, UrlLoaderMixin
from mwscanner.builders.ClassBuilder import ClassBuilder


class Discipline(TableReaderMixin, UrlLoaderMixin):
class Discipline:
# This class represents a Discipline present on
# matriculaweb. it contains data about the discipline
# and holds its classes and requirements
Expand Down
9 changes: 3 additions & 6 deletions mwscanner/builders/CampusBuilder.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import sys

import requests
from bs4 import BeautifulSoup
from requests import get

from mwscanner.builders.CoursesBuilder import CourseBuilder
from mwscanner.builders.DepartmentBuilder import DepartmentBuilder
from mwscanner.Department import Department
from mwscanner.Mixins import TableReaderMixin, UrlLoaderMixin
from mwscanner.Campus import Campus
from mwscanner import BASE_URL
Expand Down Expand Up @@ -132,7 +127,9 @@ def createDepartments(data):
return depart

pool = ThreadPool(16)
c = pool.map(createDepartments, table_data)

pool.map(createDepartments, table_data)

pool.close()
pool.join()

Expand Down
4 changes: 1 addition & 3 deletions mwscanner/builders/ClassBuilder.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from mwscanner.Class import Class
from bs4 import BeautifulSoup
import re


class ClassBuilder:

def __init__(self):
self
pass

def extractClassName(self, raw_html):
# returns the text present on the table
Expand Down
4 changes: 0 additions & 4 deletions mwscanner/builders/CoursesBuilder.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import re
import sys

import requests
from bs4 import BeautifulSoup
from requests import get

from mwscanner.Course import Course
from mwscanner.Mixins import UrlLoaderMixin
from mwscanner.Habilitation import Habilitation
from mwscanner.builders.HabilitationBuilder import HabilitationBuilder
from mwscanner import BASE_URL

Expand Down
3 changes: 0 additions & 3 deletions mwscanner/builders/DepartmentBuilder.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import requests
from bs4 import BeautifulSoup
from requests import get

from mwscanner import BASE_URL
from mwscanner.Discipline import Discipline
from mwscanner.Mixins import TableReaderMixin, UrlLoaderMixin
from mwscanner.Department import Department
from mwscanner.builders.DisciplinesBuilder import DisciplinesBuilder
Expand Down
4 changes: 0 additions & 4 deletions mwscanner/builders/DisciplinesBuilder.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import sys

import requests
from bs4 import BeautifulSoup
from requests import get

from mwscanner import BASE_URL
from mwscanner.Mixins import TableReaderMixin, UrlLoaderMixin
Expand Down
2 changes: 0 additions & 2 deletions mwscanner/builders/HabilitationBuilder.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import requests
from bs4 import BeautifulSoup
from requests import get

from mwscanner import BASE_URL
from mwscanner.Mixins import UrlLoaderMixin
Expand Down

0 comments on commit 7b9782c

Please sign in to comment.