Skip to content

Commit

Permalink
Change Versioning according to SemVer.org and added few comments in m…
Browse files Browse the repository at this point in the history
…oodleapi basic classes
  • Loading branch information
danielkauffmann committed Sep 18, 2020
1 parent c595ff7 commit d4f36d6
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
9 changes: 5 additions & 4 deletions moodleapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
"""
MOODLEAPI PACKAGE FOR REQUESTS (automatically generated by main)
LASTEST VERSION: 1.1
LASTEST VERSION: 2.0.0
STABLE VERSION: 1.1
STABLE VERSION: 2.0.0
ALL MODULES ARE INCLUDED IN THIS PACKAGE
"""

from moodleapi.version import get_version


VERSION = (1, 1, 'a')
VERSION = (2, 0, 0, 'f')

__version__ = get_version(VERSION)

__all__ = [
'settings',
'request',
'security',
'settings',
'token',
'version',

Expand Down
6 changes: 4 additions & 2 deletions moodleapi/data/calendar.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Calendar module especifically for calendar funcitons
Calendar module especifically for calendar functions
Last Update: 05/09/2020 - support for calendar_monthly
Last Update: 09/18/2020 - added new filters for events
"""

from moodleapi.request import Request
Expand All @@ -13,6 +13,8 @@


class Calendar(Request):
"""Calendar Class support montlhy informations only and have
several functions to filter information and format date."""

def __init__(self, token):
self.token = token
Expand Down
9 changes: 7 additions & 2 deletions moodleapi/data/course.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
"""
Course module ...
Course module especifically for course functions
Last Update: 09/18/2020 - support for contents and subjectsid function
"""

from moodleapi.request import Request


class Course(Request):
"""Course Class responsable to get all contents by courseid given
that can be filtered by assingments for the time beign. Also, can
get all subjects id by userid."""

def __init__(self, token):
super().__init__(token)
Expand Down Expand Up @@ -94,4 +99,4 @@ def get_subjects(self, userid=None, *args, **kwargs):
return data

else:
raise ValueError('UserID not provided or Subject not allowed. (type: int)')
raise ValueError('UserID not provided or Subject not allowed. (type: int)')
7 changes: 6 additions & 1 deletion moodleapi/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@


class Token:
"""Class Token generate an MoodleAPI token by username and password
login to automatically encrypt and storage in tokens.csv file."""

def __init__(self):
self.post = post
Expand All @@ -24,11 +26,14 @@ def __str__(self):


def create(self, username=None, password=None, discordid=None, *args, **kwargs):
"""Create function recive username and password for token creation and additionaly
discordID from respective user to be added with the encrpyted token in csv file."""

username = f'username={username}'
password = f'&password={password}'

url = f'{self.BASEURL}{self.SERVICE}{self.CONNECTION}{username}{password}{self.PLATFORM}'
data = self.post(url).json()


return Export('tokens').to_csv(data=[[Cryptography().encrypt_message(data['token']), discordid],], addstyle=True)
return Export('tokens').to_csv(data=[[Cryptography().encrypt_message(data['token']), discordid],], addstyle=True)
6 changes: 3 additions & 3 deletions moodleapi/version.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
Version module contain functions to return stable and lastest version
Version module contains functions to return stable and lastest version
"""


from datetime import datetime
from datetime import datetime as dt


def get_version(version=None):
Expand All @@ -15,4 +15,4 @@ def get_version(version=None):

else:
sufix = 'FINAL' if version[2] == 'f' else 'ALPHA'
return f'Core version {version[0]}.{version[1]} {sufix} - last time checked: {datetime.utcnow()}'
return f'Core version {version[0]}.{version[1]}.{version[2]} {sufix} - last time checked: {dt.utcnow()}'

0 comments on commit d4f36d6

Please sign in to comment.