Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
# exit-zero treats all errors as warnings. The GitHub editor is 130 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=130 --statistics
# - name: Test with pytest
# run: |
# pytest
26 changes: 23 additions & 3 deletions GithubCloner2022.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@

from Modules.DataFrameHandler_Mod.DFHandler import DataFrameHandler as DfH
from Modules.DataManager_Mod.DataManager import DataManager as DM
from Modules.DirectoryManager_Mod.DirManager import DirectoryManager as DirM
from Modules.Formatter_Mod.Formatter import Formatter as FMT
from Modules.PlotManager_Mod.PlotManager import PlotManager as Plot
from Modules.PrintMessage_Mod.CloneMessenger import CloneMessenger as CM


# ?######### Start Basic Configuration ##########
filename = 'Github_Repositories.csv'
name = 'Github Repository Cloner'
version = '[V2.0.12]'
version = '[V2.1.1]'
author = '[FacuFalcone - CaidevOficial]'
fileConfigName = 'Modules/API_Info.json'
# ?######### End Basic Configuration ##########
Expand All @@ -40,17 +41,28 @@
JsonFile = pd.read_json(f"./{fileConfigName}", orient='records')
JsonAPI = JsonFile['Github']
JsonDFConfigs = JsonFile['DataFrame']['Fields']
JsonDirConfigs = JsonFile['Files']
# ?#########? End Initialization ############

# ?#########? Start Objects Instances ##########
Handler = DfH()
Manager = DM()
Messenger = CM()
Timer = FMT()
Plotter = Plot()
DirManager = DirM()
# ?#########? End Objects Instances ##########

# ?#########? Start Directory Creation ##########
DirManager.PathToCreate = JsonDirConfigs['Dir_Plots_img']
DirManager.createDirIfNoExist()

DirManager.PathToCreate = JsonDirConfigs['Dir_Cloned_Repos']
DirManager.createDirIfNoExist()
# ?#########? End Directory Creation ##########

# ?#########? Start DataManager Configuration ##########
Manager.InitialConfig(name, version, author, JsonAPI)
Manager.InitialConfig(name, version, author, JsonAPI, JsonDirConfigs['Dir_Cloned_Repos'])
# ?#########? End DataManager Configuration ##########

# ?#########? Start DataFrame Configuration ##########
Expand All @@ -66,6 +78,10 @@
# ?#########? Start Initialize DataManager ##########
Manager.CloneRepositories(Handler)
# ?##########? End Initialize DataManager ###########

# ?#########? Start PlotManager Configuration ##########
Plotter.initialize(Handler, 'Repositories to Clone', JsonDirConfigs['Dir_Plots_img'])

except Exception as e:
print(f'Exception: {e.args}')
finally:
Expand All @@ -79,6 +95,10 @@
Messenger.Message = f"Thanks for using {name} {version} by {author}! ♥"
Messenger.PrintMessage()

Messenger.Message = "Creating Pie Chart..."
Messenger.PrintMessage()
Plotter.createPieChart()

Messenger.Message = "Success! All task done. Press a key to close the app"
Messenger.PrintMessage()
# ?#########? End Print Message ##########
Expand Down
13 changes: 9 additions & 4 deletions Github_Repositories.csv
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
"Marca temporal","Nombre/s","Apellido/s","División","DNI / Legajo","E-Mail","Link al repositorio"
"2022/02/13 10:26:52 p. m. GMT-3","Neptune","Romane God","1G - Professor 1 - Helper 1","222222","neptune@notplanet.com","https://github.com/caidevOficial/Python_RepositoryCloner"
"2022/02/13 10:26:52 p. m. GMT-3","Poseidon","Grecian God","1F - Professor 2 - Helper 2","333333","poseidon@sea.com","https://github.com/caidevOficial/Python_ITBA_IEEE"
"2022/02/13 10:26:52 p. m. GMT-3","Hades","Grecian God","1F - Professor 2 - Helper 2","111111","Hades@underworld.com","https://github.com/caidevOficial/CaidevOficial.git"
"2022/02/13 10:26:52 p. m. GMT-3","Hades "," Grecian God","1A - Professor 1 - Helper 3","111111","Hades@underworld.com","https://github.com/caidevOficial/CaidevOficial.git"
"2022/02/13 10:26:52 p. m. GMT-3","Zeus","Grecian God","1G - Professor 1 - Helper 1","444444","zeus@ray.com","https://github.com/caidevOficial/Python_RepositoryCloner.git"
"2022/02/13 10:26:52 p. m. GMT-3","Mercury","Romane God","1G - Professor 1 - Helper 1","222222","neptune@notplanet.com","https://github.com/caidevOficial/SPD2022_TPS.git"
"2022/02/13 10:26:52 p. m. GMT-3","Artemisa","Grecian God","1G - Professor 1 - Helper 1","444444","zeus@ray.com","https://github.com/caidevOficial/Python_IEEE_Team14293.git"
"2022/02/13 10:26:52 p. m. GMT-3","Artemisa","Grecian God","1H - Professor 3 - Helper 4","444444","zeus@ray.com","https://github.com/caidevOficial/Python_IEEE_Team14293.git"
"2022/02/13 10:26:52 p. m. GMT-3","Helios","Romane God","1F - Professor 2 - Helper 2","555555","Helios@notsun.com","https://github.com/caidevOficial/Python_RepositoryCloner"
"2022/02/13 10:26:52 p. m. GMT-3","Odin","Nordic God","1G - Professor 1 - Helper 1","777777","odin@fatherofall.com","https://github.com/caidevOficial/Python_RepositoryCloner.git"
"2022/02/13 10:26:52 p. m. GMT-3","Odin","Nordic God","1A - Professor 1 - Helper 3","777777","odin@fatherofall.com","https://github.com/caidevOficial/Python_RepositoryCloner.git"
"2022/02/13 10:26:52 p. m. GMT-3","Thor","Nordic God","1F - Professor 2 - Helper 2","888888","thor@thundergod.com","https://github.com/caidevOficial/Python_RepositoryCloner"
"2022/02/13 10:26:52 p. m. GMT-3","Loki","Nordic God","1G - Professor 1 - Helper 1","888888","loki@trapgod.com","https://github.com/caidevOficial/Python_RepositoryCloner"
"2022/02/13 10:26:52 p. m. GMT-3","Valhalla","Nordic Reign","1F - Professor 2 - Helper 2","999999","valhalla@nordicreign.com","https://github.com/caidevOficial/Python_RepositoryCloner"
"2022/02/13 10:26:52 p. m. GMT-3","Valhalla","Nordic Reign","1A - Professor 1 - Helper 3","999999","valhalla@nordicreign.com","https://github.com/caidevOficial/CaidevOficial"
"2022/02/13 10:26:52 p. m. GMT-3","Medusa","Grecian Monster","1C - Professor 5 - Helper 5","999999","Medusa@nordicreign.com","https://github.com/caidevOficial/CaidevOficial"
"2022/02/13 10:26:52 p. m. GMT-3","Heracles","Grecian DemiGod","1A - Professor 1 - Helper 3","999999","Heracles@nordicreign.com","https://github.com/caidevOficial/CaidevOficial"
"2022/02/13 10:26:52 p. m. GMT-3","Prometeus","Grecian Giant","1B - Professor 4 - Helper 1","999999","Prometeus@nordicreign.com","https://github.com/caidevOficial/CaidevOficial"
"2022/02/13 10:26:52 p. m. GMT-3","Cronos","Grecian Titan","1C - Professor 5 - Helper 5","999999","Cronos@nordicreign.com","https://github.com/caidevOficial/CaidevOficial"
"2022/02/13 10:26:52 p. m. GMT-3","GEA","Grecian Titan","1H - Professor 3 - Helper 4","999999","GEA@nordicreign.com","https://github.com/caidevOficial/CaidevOficial"
Binary file added Media/pieChart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions Modules/API_Info.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
},
"DataFrame": {
"Fields": {
"Date": "Marca temporal",
"Name": "Nombre/s",
"Surname": "Apellido/s",
"Course": "División",
"ID": "DNI / Legajo",
"Email": "E-Mail",
"GitLink": "Link al repositorio"
}
},
"Files": {
"Dir_Plots_img": "./Plot_Images",
"Dir_Cloned_Repos": "./Repositories"
}
}
30 changes: 27 additions & 3 deletions Modules/DataManager_Mod/DataManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class DataManager:
[class]: [DataManager]. \n
"""
# ?########? START ATTRIBUTES #########
__mainDir: str = ''
__configAPIURL = ''
__APIResponse = None
__APIDate = None
Expand Down Expand Up @@ -138,6 +139,15 @@ def APIDate(self) -> str:
"""
return self.__APIDate

@property
def MainDir(self) -> str:
"""[summary] \n
Get the main directory to save the downloaded repositories. \n
Returns:
str: [The main directory to save the downloaded repositories]. \n
"""
return self.__mainDir

# ?########? END PROPERTIES - GET #########

# ?########? START PROPERTIES - SET #########
Expand Down Expand Up @@ -230,11 +240,20 @@ def APIDate(self, APIResponse: str):
date = date[:10]
self.__APIDate = date.replace("-", "")

@MainDir.setter
def MainDir(self, mainDir: str) -> None:
"""[summary] \n
Set the main directory to save the downloaded repositories. \n
Args:
mainDir (str): [The main directory to save the downloaded repositories]. \n
"""
self.__mainDir = mainDir.strip()

# ?#######? END PROPERTIES - SET #########

# ?########? METHODS #########

def InitialConfig(self, name: str, version: str, author: str, APIURL: dict):
def InitialConfig(self, name: str, version: str, author: str, APIURL: dict, mainDir: str):
"""[summary] \n
Initialize the config of the class, Also sets the API response \n
and the date of the API. \n
Expand All @@ -243,13 +262,15 @@ def InitialConfig(self, name: str, version: str, author: str, APIURL: dict):
version (str): [The version of the program]. \n
author (str): [The author of the program]. \n
APIURL (dict): [The API URL of the program]. \n
mainDir (str): [The main directory to clone repositories]. \n
"""
self.AppName = name
self.AppVersion = version
self.AppAuthor = author
self.APIURL = APIURL
self.APIResponse = self.APIURL
self.APIDate = self.APIResponse
self.MainDir = mainDir

def AddComand(self, command: str) -> None:
"""[summary] \n
Expand Down Expand Up @@ -315,14 +336,17 @@ def MakeCloneCommands(self, dfHandler: DFH) -> None:
git (str): [The url of the git's repository]. \n
"""
for frame in dfHandler.OrderListOfDFStudents:
self.MakeCloneCommandsForDF(frame, dfHandler)
self.MakeCloneCommandsForDF(frame.reset_index(drop=True), dfHandler)

def MakeCloneCommandsForDF(self, df: DataFrame, dfHandler: DFH) -> None:
"""[summary] \n
Make the commands to clone the repositories of the students. \n
Args:
df (DataFrame): [The DataFrame with the students information]. \n
"""
# *## Deletes the first column [Date]
df = df.drop(columns=dfHandler.ConfigsJsonValues['Date'], inplace=False, axis=1)
df = df.applymap(lambda x: str(x).strip())
for i in df.index:
crudeCourse = df[dfHandler.ConfigsJsonValues['Course']][i]
courseStr = self.NormalizeCourse(self.FormatCourse(crudeCourse))
Expand All @@ -332,7 +356,7 @@ def MakeCloneCommandsForDF(self, df: DataFrame, dfHandler: DFH) -> None:
normalizedURL = self.NormalizeURL(
df[dfHandler.ConfigsJsonValues['GitLink']][i])
normalizedFullname = self.FormatFullnameDate(surnameStr, nameStr)
command = f"git clone {normalizedURL} {courseStr}//{normalizedFullname}"
command = f"git clone {normalizedURL} {self.MainDir}//{courseStr}//{normalizedFullname}"
self.AddComand(command)
self.CloningMessages = message

Expand Down
58 changes: 58 additions & 0 deletions Modules/DirectoryManager_Mod/DirManager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# GNU General Public License V3
#
# Copyright (c) 2022 [FacuFalcone]
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import os


class DirectoryManager:
"""[summary]
Class in charge of create directories. \n
Returns:
class: DirectoryManager
"""
# ?#### START ATTRIBUTES ####?
__dirToCreate: str = ''
# ?#### END ATTRIBUTES ####?

def __init__(self) ->None:
pass

@property
def PathToCreate(self)-> str:
"""[summary]
Gets the path that need to create if not exist. \n
Returns:
str: [Path to create.]
"""
return self.__dirToCreate

@PathToCreate.setter
def PathToCreate(self, path: str)->None:
"""[summary]
Sets the directory that will create. \n
Args:
path (str): [Directory to create.]
"""
self.__dirToCreate = path

def createDirIfNoExist(self)->None:
"""[summary]
Creates the directory if not exist. \n
"""
if not os.path.exists(self.PathToCreate):
os.makedirs(self.PathToCreate)

16 changes: 16 additions & 0 deletions Modules/DirectoryManager_Mod/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# GNU General Public License V3
#
# Copyright (c) 2022 [FacuFalcone]
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
Loading