Giter VIP home page Giter VIP logo

intrapy's Introduction

Hi there, My name's Jules - aka Seluj78 ๐Ÿ‘‹

Website Twitter Follow StackShare wakatime

I'm a Developper, DJ and Scout Leader

  • ๐Ÿ”ญ Iโ€™m currently working as a Senior Python Backend developper for Datascientest
  • ๐ŸŒฑ Iโ€™m currently looking for more open source projects to contribute to/create more packages/projects for people to use!

Spotify Playing ๐ŸŽง

Seluj78 Spotify Playing

Connect with me:

juleslasne.com Seluj78 | Twitter Seluj78 | LinkedIn Seluj78 | Instagram


Languages and Tools:

Python

Flask

SQL

MySQL

Git

GitHub

Terminal




โšก Recent Github Activity

  1. ๐Ÿ—ฃ Commented on #716 in kubenav/kubenav
  2. ๐Ÿ—ฃ Commented on #10986 in traefik/traefik
  3. ๐Ÿ—ฃ Commented on #716 in kubenav/kubenav
  4. ๐Ÿ—ฃ Commented on #10986 in traefik/traefik
  5. ๐Ÿ—ฃ Commented on #716 in kubenav/kubenav

โšก Github Stats

Seluj78's Github Stats










Original idea from https://github.com/codeSTACKr

intrapy's People

Contributors

bidoubiwa avatar seluj78 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

intrapy's Issues

Darwin-Linux compatibility

The pythonic way to push into PyPi is different between macosX and Linux.


# @todo Darwin-Linux compatibility
# @body The pythonic way to push into PyPi is different between macosX and Linux.
git push --tags origin master
python setup.py register sdist upload


This issue was generated by todo based on a @todo comment in 8a48ea7. It's been assigned to @Seluj78 because they committed the code.

.app_token file check

The script doesnt check correctly if the file exists

And if the token is expired, you have to delete the file and rerun the script. We need a correct way to test the token that is in the .app_token file

Auto commit/push in update.sh

# @todo Auto commit/push in update.sh
echo "Error: $1 not found in setup.py. I just replaced it, please commit and push then start this script again"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
echo
if [[ ! $(grep -q "$1" IntraPy/__init__.py && echo $?) ]]
then
sed -i '' 's/'"$old"'/'"$1"'/g' IntraPy/__init__.py
echo "Error: $1 not found in IntraPy/__init__.py. I just replaced it, please commit and push then start this script again"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi


This issue was generated by todo based on a @todo comment in 8a48ea7. It's been assigned to @Seluj78 because they committed the code.

Auto check if pushed in update.sh

# @todo: Auto check if pushed in update.sh
echo "\n\nDid you commit and pushed your last changes ? The last commit found is:"
git log | head -n 5
read -p "Is that ok? " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
if [ ! -f ~/.pypirc ]; then


This issue was generated by todo based on a TODO: comment in 8a48ea7. It's been assigned to @Seluj78 because they committed the code.

Extended documentation

IntraPy/IntraPy/args.py

Lines 25 to 35 in 3e5c041

TODO: Extended documentation
TODO: Better error handling and error messages
If page_number is explicitely set through options when calling test_get, then the return will be the page PAGE_NUMBER.
If from_page and to_page are set, it will loop through them
Else, it will do all the pages until return is empty
"""
options = {}


This issue was generated by todo based on a TODO: comment in 3e5c041. It's been assigned to @Seluj78 because they committed the code.

Shorten error messages

IntraPy/IntraPy/args.py

Lines 109 to 119 in efc8302

@todo Shorten error messages
"""
raise ValueError("Wrong value for `range` parameter: '" + options.get("range", "id")[options.get("range", "id").find("[") + 1:options.get("range", "id").find("]")] + "'")
return True
def sanitize_keyword_string(self, string, rules):
"""
This function will split the `sort` string `string` into keyword and
compare each one to the given rules.
:param string: The string to split into keywords


This issue was generated by todo based on a @todo comment in efc8302. It's been assigned to @Seluj78 because they committed the code.

Add /oauth/token/info

We need to add the /oauth/token/info and parse the infos it returns such as expiration date, creation time etc

Multiple tokens

What if we could handle multiple tokens ?

With an int you changed when making a resquest ? This needs to be discussed

Add multiple sorts

Multiple sort parameters isn't handled, eg. sort="one"&sort="two"


IntraPy/IntraPy/args.py

Lines 105 to 115 in 3e5c041

# @todo Add multiple sorts
# @body Multiple sort parameters isn't handled, eg. `sort="one"&sort="two"`
if not isinstance(string, str):
raise ValueError("sort must be a String")
# Create a list (with separator `'`)containing each word
keyword = string.split(',')
# Remove `-` before comparison
for i, s in enumerate(keyword):
keyword[i] = re.sub(r'-', '', s)
# Compare each Keyword with the rules


This issue was generated by todo based on a @todo comment in 3e5c041. It's been assigned to @Seluj78 because they committed the code.

TOKEN_FILE empty

If TOKEN_FILE variable is not present in the settings.ini file, it will be created as None. it should have a default value

filter not working as intended

from IntraPy.accreditation_handler import accreditations

accreditations = accreditations.Accreditations()
print(accreditations.get_accreditations(pretty=True, filter="[id]=2"))

or

from IntraPy.accreditation_handler import accreditations

accreditations = accreditations.Accreditations()
print(accreditations.get_accreditations(pretty=True, filter="[id]=1,2"))

doesn't work either

Add pretty option on api_get_single

IntraPy/IntraPy/IntraPy.py

Lines 148 to 158 in b56f219

@todo Add pretty option on api_get_single
"""
def api_get_single(self, uri: str, methods="GET"):
"""
This function will handle all the API requests that send a single json response back.
If the token suddenly expires, this function will call check_token
and then recursively call itself again until the token works.
:param uri: The url you want to request from
:param methods: The method you want to to your API request on. By default, `methods` is set to `GET`


This issue was generated by todo based on a @todo comment in b56f219. It's been assigned to @Seluj78 because they committed the code.

Change the ifs into a dict/list for get_expire_time

IntraPy/IntraPy/IntraPy.py

Lines 209 to 219 in c9a5ae5

# @todo: Change the ifs into a dict/list for get_expire_time
# @todo: Add /v2/campus and /v2/cursus in get_expire_time
def get_expire_time_seconds(self, endpoint: str):
if endpoint == "/oauth/token/info":
return "1" # 1 second
if endpoint == "/v2/accreditations":
return "86400" # 1 day
if endpoint == "/v2/achievements":
return "2629746" # 1 month
if endpoint == "/v2/titles":
return "2629746" # 1 month


This issue was generated by todo based on a TODO: comment in c9a5ae5. It's been assigned to @Seluj78 because they committed the code.

Change the endpoint to test tokens

Currently, the endpoint use to test the validity of the token is /v2/accreditations?page[size]=1.

This needs to be changed to use /oauth/token/info

Test the filter option

We haven't tested enough if the filter option works as intended


IntraPy/IntraPy/args.py

Lines 127 to 137 in 3e5c041

# @todo Test the filter option
# @body We haven't tested enough if the filter option works as intended
keyword = re.match(r"\[(.*?)\]", string)
if keyword is None:
print("ERROR : filter bad format")
return False
keyword = keyword.groups()
return self.compare_with_rules(rules, keyword)
def compare_with_rules(self, rules, keyword):


This issue was generated by todo based on a @todo comment in 3e5c041. It's been assigned to @Seluj78 because they committed the code.

Refactor utility token info methods

these functions are deprecated and needs to be refactored


IntraPy/IntraPy/IntraPy.py

Lines 198 to 208 in 386fcea

@todo Refactor utility token info methods
@body these functions are deprecated and needs to be refactored
"""
"""
def get_uid_from_token(self):
response = self.api_get("/oauth/token/info")
ret = json.loads(response.content)
return ret["application"]["uid"]
def get_token_expire_time_in_seconds(self):


This issue was generated by todo based on a @todo comment in 386fcea. It's been assigned to @Seluj78 because they committed the code.

Add /v2/campus and /v2/cursus in get_expire_time

IntraPy/IntraPy/IntraPy.py

Lines 210 to 220 in c9a5ae5

# @todo: Add /v2/campus and /v2/cursus in get_expire_time
def get_expire_time_seconds(self, endpoint: str):
if endpoint == "/oauth/token/info":
return "1" # 1 second
if endpoint == "/v2/accreditations":
return "86400" # 1 day
if endpoint == "/v2/achievements":
return "2629746" # 1 month
if endpoint == "/v2/titles":
return "2629746" # 1 month


This issue was generated by todo based on a TODO: comment in c9a5ae5. It's been assigned to @Seluj78 because they committed the code.

Utility functions for handlers

A thing that could be useful are utility functions that would parse info based on a token and return a more useful information like this one where the information returned by the endpoint is an epoch time but it is returned by get_token_creation_date as a string date

Better error handling and error messages

IntraPy/IntraPy/args.py

Lines 26 to 36 in 3e5c041

TODO: Better error handling and error messages
If page_number is explicitely set through options when calling test_get, then the return will be the page PAGE_NUMBER.
If from_page and to_page are set, it will loop through them
Else, it will do all the pages until return is empty
"""
options = {}
# @todo Add 'range' handling


This issue was generated by todo based on a TODO: comment in 3e5c041. It's been assigned to @Seluj78 because they committed the code.

Add 'pretty' option

The pretty option isn't possible in get_accreditations_by_id and should be


# @todo Add 'pretty' option
# @body The pretty option isn't possible in get_accreditations_by_id and should be
def get_accreditations_by_id(self, accreditation_id: int):
response = self.api_get_single("/v2/achievements/" + str(accreditation_id), "GET")
accreditation = json.loads(response.content)


This issue was generated by todo based on a @todo comment in a984fcc. It's been assigned to @Seluj78 because they committed the code.

Customize the expire_after for rcache

# @todo: Customize the expire_after for rcache
if self.cache_type == "rcache":
requests_cache.install_cache(self.db_name, backend='sqlite', expire_after=180)
elif self.cache_type == "sqlite":
self.connection = sqlite3.connect(self.db_name)
self.cursor = self.connection.cursor()
self.cursor.execute('CREATE TABLE IF NOT EXISTS ' + self.table_name + ' (url text, endpoint text, response text, last_requested int, expires_after int, expires_at int)')
self.connection.commit()
self.app_token = IntraPy.check_app_token(self)
def api_request_new_token(self):


This issue was generated by todo based on a TODO: comment in c9a5ae5. It's been assigned to @Seluj78 because they committed the code.

Test 1800 limit for to_page

the to_page variable has a 1800 limit set because of the api limtation. it needs to be correctly tested.


IntraPy/IntraPy/args.py

Lines 79 to 89 in eae71cd

@todo Test 1800 limit for to_page
@body the `to_page` variable has a 1800 limit set because of the api limtation. it needs to be correctly tested.
"""
self.to_page = options.get("to_page", 1800)
if not isinstance(self.to_page, int):
raise TypeError("to_page must be an int")
self.page_size = options.get("page_size", 30)
if not isinstance(self.page_size, int):
raise TypeError("page_size must be an int")
elif self.page_size > 100:
raise ValueError("page_size must be <= 100")


This issue was generated by todo based on a @todo comment in eae71cd. It's been assigned to @Seluj78 because they committed the code.

Add 'range' handling

The range option isn't currently handled


IntraPy/IntraPy/args.py

Lines 36 to 46 in 3e5c041

# @todo Add 'range' handling
# @body The `range` option isn't currently handled
def __init__(self):
self.page_number = None
self.page_size = 30
self.sort = None
self.filter = None
self.range = None
self.from_page = None
self.to_page = None


This issue was generated by todo based on a @todo comment in 3e5c041. It's been assigned to @Seluj78 because they committed the code.

Possible failure if token expires

Expected Behavior

If a token expires after init() has been called, the function, when making its request to the api, will check the return HTTP code and if it is an error, it will call a function to change the token

Actual Behavior

If a token expires after init() has been called, the function called next from the library might fail

Specifications

  • Version: 0.1.1
  • Platform: Windows

modular app_token file name

So far, the file name that stores the app_token given by the API is hard coded.

We need to make it modular, as a part of settings.ini for example

Add option priority explaination in the wiki

If page_number is explicitely set through options when calling test_get, then the return will be the page PAGE_NUMBER. If from_page and to_page are set, it will loop through them Else, it will do all the pages until return is empty. priority on page_number. 1800 requetes max pour to_page car 1800 requete en limite de l'api. a tester


IntraPy/IntraPy/args.py

Lines 30 to 40 in eae71cd

@todo Add option priority explaination in the wiki
@body If page_number is explicitely set through options when calling test_get, then the return will be the page PAGE_NUMBER. If from_page and to_page are set, it will loop through them Else, it will do all the pages until return is empty. priority on page_number. 1800 requetes max pour to_page car 1800 requete en limite de l'api. a tester
"""
options = {}
"""
@todo Add 'range' handling
@body The `range` option isn't currently handled
"""


This issue was generated by todo based on a @todo comment in eae71cd. It's been assigned to @Seluj78 because they committed the code.

Detailed Error message for wrong filter or sort parameters

Expected Behavior

ERROR : Wrong parameters for 'sort' option: 'XXX'

Actual Behavior

ERROR : Wrong parameters for 'sort' option

To do this, just refactor sanetize_keyword_string and sanitize_keyword_brackets so that they return an empty string if ok, and if error they return the bad option

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.