heig.gaps

Copyright 2019,2020 Gabriel Roch

This file is part of heig-bot.

heig-bot 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.

heig-bot 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 heig-bot. If not, see <https://www.gnu.org/licenses/>.

class heig.gaps.Gaps(user)[source]

Class for access to GAPS account

Variables:
  • _user (User) – User object for GAPS access
  • _data (User) – GAPS information _data[“notes”][2020][“ANA”] = GradeCourse _data[“gapsid”] = id for GAPS //_data[“tracking”][“notes”] = bool (true for notes tracking) _data[“tracking”][“notes”][telegramid] = true # tracking all branch _data[“tracking”][“notes”][telegramid] = [ANA, ASD1] # tracking only ANA and ASD1
__dict__ = mappingproxy({'__module__': 'heig.gaps', '__doc__': '\n Class for access to GAPS account\n\n :ivar _user: User object for GAPS access\n :vartype _user: User\n\n :ivar _data: GAPS information\n _data["notes"][2020]["ANA"] = GradeCourse\n _data["gapsid"] = id for GAPS\n //_data["tracking"]["notes"] = bool (true for notes tracking)\n _data["tracking"]["notes"][telegramid] = true # tracking all branch\n _data["tracking"]["notes"][telegramid] = [ANA, ASD1] # tracking only ANA and ASD1\n :vartype _data: User\n ', '__init__': <function Gaps.__init__>, 'tracking': <function Gaps.tracking>, 'tracking_get_telegram_id': <function Gaps.tracking_get_telegram_id>, 'set_tracking': <function Gaps.set_tracking>, 'is_registred': <function Gaps.is_registred>, 'get_timetable_ics': <function Gaps.get_timetable_ics>, 'get_day_lesson': <function Gaps.get_day_lesson>, 'set_credentials': <function Gaps.set_credentials>, 'unset_credentials': <function Gaps.unset_credentials>, 'get_notes_online': <function Gaps.get_notes_online>, 'get_notes': <function Gaps.get_notes>, 'send_notes_course': <function Gaps.send_notes_course>, 'send_notes': <function Gaps.send_notes>, 'send_notes_all': <function Gaps.send_notes_all>, 'send_diff_gaps_notes': <function Gaps.send_diff_gaps_notes>, 'check_gaps_notes': <function Gaps.check_gaps_notes>, '__dict__': <attribute '__dict__' of 'Gaps' objects>, '__weakref__': <attribute '__weakref__' of 'Gaps' objects>})
__init__(user)[source]

Make a Gaps object

Parameters:user (User) – User object for configuration
__module__ = 'heig.gaps'
__weakref__

list of weak references to the object (if defined)

check_gaps_notes(chat_id=None)[source]

Check update on GAPS

Parameters:chat_id (int) – send message to this chat id (else send a private message)
get_day_lesson(dt: arrow.arrow.Arrow = <Arrow [2020-07-17T10:28:34.386178+00:00]>, text: bool = False)[source]
Parameters:
  • dt – Date for show lesson
  • text – Return type is text
get_notes(year)[source]

Get notes from cache, if no cache for this year download from GAPS

Parameters:year – Year to get (for 2020-2021 is 2020)
get_notes_online(year)[source]

Get notes from GAPS

Parameters:year – Year to get (for 2020-2021 is 2020)
get_timetable_ics(year, trimester, id, type, force=False)[source]

Get ICS file. File in cache is used if possible.

Parameters:
  • year (int) – Year of timetable
  • trimester (int) – Trimester of timetable
  • id (int) – id of entity
  • type (int) – type of entity
  • force (bool) – Force download and update cache
is_registred()[source]

Indicate if we have credentials for GAPS

send_diff_gaps_notes(chat_id, oldnotes, newnotes, year, branches=None) → bool[source]
send_notes(year, courses, chat_id)[source]

Send notes for multiple branche

Parameters:
  • year – Year to send (for 2020-2021 is 2020)
  • courses – list of branchname to send
  • chat_id (int) – send message to this chat id
send_notes_all(chat_id)[source]

Send all notes in cache

Parameters:chat_id (int) – send message to this chat id
send_notes_course(year, course, chat_id, notes=0, prefix='')[source]

Send notes for branche

Parameters:
  • year – Year to send (for 2020-2021 is 2020)
  • course (str) – branchname to send
  • chat_id (int) – send message to this chat id
  • notes – notes to send, if isn’t specified, it’s getted from cache or online
  • prefix (str) – prefix of message to user
set_credentials(username, password)[source]

Set credentials for GAPS

Parameters:
  • username (str) – GAPS username, it can be different to SSO
  • password (str) – GAPS password
set_tracking(type, branch_list, user_id=None) → None[source]

Set tracking mode for type

Parameters:
  • type (str) – Type of tracking (notes, …)
  • branch_list (bool|string array) – True for enable tracking all branch, also an array of list branch
  • user_id (int) – telegram id for send message
Return type:

None

tracking(type='notes', user_id=None)[source]

Indicate if tracking is enable

Parameters:
  • user_id (int) – telegram id for send message
  • type (str) – Type of tracking (notes, …)
Return type:

bool | list of branch

tracking_get_telegram_id(type='notes')[source]

Get telegram id list for tracking

Parameters:type (str) – Type of tracking (notes, …)
Return type:list of int
unset_credentials()[source]
exception heig.gaps.GapsError[source]

Class for manage exception on Gaps

__module__ = 'heig.gaps'
__weakref__

list of weak references to the object (if defined)

class heig.gaps.GradeCourse(name, average)[source]

Class for stockage of grade course.

Cette classe corresponds à une branche

Variables:
  • name (str) –
  • average
  • evals
__dict__ = mappingproxy({'__module__': 'heig.gaps', '__doc__': '\n Class for stockage of grade course.\n\n Cette classe corresponds à une branche\n\n :ivar name: \n :vartype name: str\n\n :ivar average: \n :vartype average:\n\n :ivar evals: \n :vartype evals:\n ', '__init__': <function GradeCourse.__init__>, 'serilizable': <function GradeCourse.serilizable>, 'diff': <classmethod object>, 'eq': <classmethod object>, 'str': <function GradeCourse.str>, '__dict__': <attribute '__dict__' of 'GradeCourse' objects>, '__weakref__': <attribute '__weakref__' of 'GradeCourse' objects>})
__init__(name, average)[source]

Make a new GradeCourse object

Parameters:
  • name (str) – Name of course
  • average – Average of course for user
__module__ = 'heig.gaps'
__weakref__

list of weak references to the object (if defined)

classmethod diff(a, b, year, level='full')[source]
classmethod eq(a, b, level='full')[source]
serilizable()[source]
str(year, prefix=' ', level='full')[source]
class heig.gaps.GradeEvaluation(description, date, classaverage, grade, coeff)[source]

Class for stockage of a evaluation

Variables:
  • date
  • description
  • classaverage
  • grade
  • coeff
__dict__ = mappingproxy({'__module__': 'heig.gaps', '__doc__': '\n Class for stockage of a evaluation\n\n :ivar date: \n :vartype date:\n\n :ivar description: \n :vartype description:\n\n :ivar classaverage: \n :vartype classaverage:\n\n :ivar grade: \n :vartype grade:\n\n :ivar coeff: \n :vartype coeff:\n ', '__init__': <function GradeEvaluation.__init__>, 'serilizable': <function GradeEvaluation.serilizable>, 'diff': <classmethod object>, 'eq': <classmethod object>, 'str': <function GradeEvaluation.str>, '__dict__': <attribute '__dict__' of 'GradeEvaluation' objects>, '__weakref__': <attribute '__weakref__' of 'GradeEvaluation' objects>})
__init__(description, date, classaverage, grade, coeff)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'heig.gaps'
__weakref__

list of weak references to the object (if defined)

classmethod diff(a, b, level='full')[source]
Parameters:
Returns:

classmethod eq(a, b, level='full')[source]
Parameters:
Returns:

serilizable()[source]
str(prefix=' ', level='full')[source]
class heig.gaps.GradeGroupEvaluation(average, coeff)[source]

Class for stockage of grade group of evaluation

Cette classe corresponds à un groupe d’une branche (labo ou controlecontinus)

Variables:
  • average
  • coeff
  • evals
__dict__ = mappingproxy({'__module__': 'heig.gaps', '__doc__': "\n Class for stockage of grade group of evaluation\n\n Cette classe corresponds à un groupe d'une branche (labo ou controlecontinus)\n\n :ivar average: \n :vartype average:\n\n :ivar coeff: \n :vartype coeff:\n\n :ivar evals: \n :vartype evals:\n ", '__init__': <function GradeGroupEvaluation.__init__>, 'serilizable': <function GradeGroupEvaluation.serilizable>, 'diff': <classmethod object>, 'eq': <classmethod object>, 'str': <function GradeGroupEvaluation.str>, '__dict__': <attribute '__dict__' of 'GradeGroupEvaluation' objects>, '__weakref__': <attribute '__weakref__' of 'GradeGroupEvaluation' objects>})
__init__(average, coeff)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'heig.gaps'
__weakref__

list of weak references to the object (if defined)

classmethod diff(a, b, typ, level='full')[source]
classmethod eq(a, b, level='level')[source]
serilizable()[source]
str(typ, prefix=' ', level='full')[source]