-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleaned up code , replaced simplejson with orjson for better performa…
…nce , got rid of jsonobjects and replaced with dataclasses
- Loading branch information
Showing
22 changed files
with
398 additions
and
423 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
# personal files | ||
**/trash | ||
### Python ### | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# poetry | ||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. | ||
# This is especially recommended for binary packages to ensure reproducibility, and is more | ||
# commonly ignored for libraries. | ||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | ||
#poetry.lock | ||
|
||
# pdm | ||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. | ||
#pdm.lock | ||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it | ||
# in version control. | ||
# https://pdm.fming.dev/#use-with-ide | ||
.pdm.toml | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# PyCharm | ||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can | ||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
# and can be added to the global gitignore or merged into this file. For a more nuclear | ||
# option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
#.idea/ | ||
|
||
### Python Patch ### | ||
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration | ||
poetry.toml | ||
|
||
|
||
# End of https://www.toptal.com/developers/gitignore/api/python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "run vs_api", | ||
"type": "shell", | ||
"command": "cd ${cwd}/src/;conda activate vs-api;python main.py" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,4 @@ dependencies: | |
- pip | ||
- pip: | ||
- httpx | ||
- simplejson | ||
- ndicts | ||
- jsonobject | ||
- orjson |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
httpx | ||
simplejson | ||
ndicts | ||
jsonobject | ||
orjson |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from .info import info | ||
from .namespace import namespace | ||
from .publisher import publisher | ||
from .reviews import reviews | ||
from .search import search | ||
|
||
__all__ = ["info","namespace","reviews","search"] | ||
__all__ = ["info","publisher","reviews","search"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,10 @@ | ||
from typing import Any | ||
import httpx | ||
import orjson as json | ||
|
||
def info(uid: str, client: httpx.Client) -> tuple[bytes, int]: | ||
""" | ||
returns info on extension | ||
|
||
Args: | ||
id (str): unique identifier of extension | ||
client (httpx.Client): httpx http client | ||
Returns: | ||
tuple[bytes, int]: tuple('api response','api status code') | ||
""" | ||
def info(uid: str, client: httpx.Client) -> tuple[Any, int]: | ||
|
||
endpoint = uid | ||
r = client.get(url=endpoint) | ||
return (r.content, r.status_code) | ||
return (json.loads(r.content), r.status_code) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from typing import Any | ||
import httpx | ||
import orjson as json | ||
|
||
|
||
def publisher(namespace:str,client:httpx.Client) -> tuple[Any, int]: | ||
|
||
endpoint = f"/{namespace}" | ||
r = client.get(url=endpoint) | ||
return (json.loads(r.content),r.status_code) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,10 @@ | ||
from typing import Any | ||
import httpx | ||
import orjson as json | ||
|
||
def reviews(uid:str,client:httpx.Client) -> tuple[bytes, int]: | ||
""" | ||
returns all reviews of an extension | ||
|
||
Args: | ||
uid (str): extension unique identifier | ||
client (httpx.Client): httpx http client | ||
Returns: | ||
tuple[bytes, int]: tuple('api response','api status code') | ||
""" | ||
def reviews(uid:str,client:httpx.Client) -> tuple[Any, int]: | ||
|
||
endpoint = f"{uid}/reviews" | ||
r = client.get(url=endpoint) | ||
return (r.content,r.status_code) | ||
return (json.loads(r.content),r.status_code) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,12 @@ | ||
from typing import Any | ||
import httpx | ||
import orjson as json | ||
|
||
def search(query:str,size:int,category:str,sortBy: str,sortOrder:str,client:httpx.Client) -> tuple[bytes, int]: | ||
""" | ||
returns info on extensions that match the query | ||
|
||
Args: | ||
query (str): search by name,desc or keywords | ||
size (int): no.of results to fetch | ||
category (str): category of extension to display | ||
sortBy (str): sorting of extensions | ||
sortOrder (str): sorting in ascending or descending | ||
client (httpx.Client): httpx http client | ||
|
||
Returns: | ||
tuple[bytes, int]: tuple('api response','api status code') | ||
""" | ||
def search(query:str,size:int,category:str,sortBy: str,sortOrder:str,client:httpx.Client) -> tuple[Any, int]: | ||
|
||
|
||
endpoint = f"/-/search?query={query}&size={size}&category={category}&sortBy={sortBy}&sortOrder={sortOrder}" | ||
r = client.get(url=endpoint) | ||
return (r.content,r.status_code) | ||
return (json.loads(r.content),r.status_code) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from .ExtensionNotFound import ExtensionNotFound | ||
from .PublisherNotFound import PublisherNotFound | ||
from .extension_not_found import ExtensionNotFound | ||
from .publisher_not_found import PublisherNotFound | ||
|
||
__all__ = ["ExtensionNotFound","PublisherNotFound"] | ||
__all__ = ["extension_not_found","publisher_not_found"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
from . import info, namespace, reviews, search | ||
|
||
from .publisher import publisher | ||
from .info import info | ||
from .search import search | ||
from .reviews import reviews | ||
|
||
|
||
__all__ = ["publisher","info","search","reviews"] |
Oops, something went wrong.