Skip to content

Add fallback api ressource #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-20.04, macos-latest, windows-latest]
exclude:
- os: macos-latest
python-version: ["3.7", "3.8", "3.9"]
Expand Down
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.3.3
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
24 changes: 14 additions & 10 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,30 @@
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import os, sys
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'python-glinet'
copyright = '2022, Tomtana'
author = 'Tomtana'
project = "python-glinet"
copyright = "2022, Tomtana"
author = "Tomtana"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = ['myst_parser', 'sphinx.ext.autodoc', 'sphinx_toolbox.collapse', "sphinx.ext.viewcode"]
extensions = [
"myst_parser",
"sphinx.ext.autodoc",
"sphinx_toolbox.collapse",
"sphinx.ext.viewcode",
]

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
autoclass_content = 'both'
templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
autoclass_content = "both"


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']
html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]
54 changes: 29 additions & 25 deletions docs/conversion_filter.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
from pandocfilters import toJSONFilter, Emph, CodeBlock, toJSONFilters, Strong, BulletList, Div, Plain, Para, Str
from pandocfilters import (
CodeBlock,
Para,
Str,
Strong,
toJSONFilters,
)

def remove_collapse(key, value, format, meta):
try:
if key == 'Div' and value[0][1] == ["collapse"]:
return CodeBlock(*value[1][1].get('c'))
except IndexError:
return None

def convert_warning(key, value, format, meta):
if key == 'Div':
[[identification, classes, keyvals], content] = value
if classes == ["note"]:

bl = content[1]
para = Para([Strong([Str("Note:")])])
#div = Div(["", ["note"], []], [note, bl])
#raise IOError(bl)
return [para, bl]
if classes == ["warning"]:

bl = content[1]
para = Para([Strong([Str("Warning:")])])
#div = Div(["", ["note"], []], [note, bl])
#raise IOError(bl)
return [para, bl]
def remove_collapse(key, value, format, meta):
try:
if key == "Div" and value[0][1] == ["collapse"]:
return CodeBlock(*value[1][1].get("c"))
except IndexError:
return None


def convert_warning(key, value, format, meta):
if key == "Div":
[[identification, classes, keyvals], content] = value
if classes == ["note"]:
bl = content[1]
para = Para([Strong([Str("Note:")])])
# div = Div(["", ["note"], []], [note, bl])
# raise IOError(bl)
return [para, bl]
if classes == ["warning"]:
bl = content[1]
para = Para([Strong([Str("Warning:")])])
# div = Div(["", ["note"], []], [note, bl])
# raise IOError(bl)
return [para, bl]


if __name__ == "__main__":
toJSONFilters([remove_collapse, convert_warning])
toJSONFilters([remove_collapse, convert_warning])
12 changes: 9 additions & 3 deletions pyglinet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
python-pyglinet json-rpc api client

"""
__author__ = 'Thomas Fontana'

from pyglinet.glinet import GlInet
__author__ = "Thomas Fontana"

import logging
import sys

logging.basicConfig(stream=sys.stdout, level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
from pyglinet.glinet import GlInet as GlInet

logging.basicConfig(
stream=sys.stdout,
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
)
5 changes: 4 additions & 1 deletion pyglinet/decorators.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from functools import wraps

import pyglinet.exceptions as exceptions


Expand All @@ -8,7 +9,9 @@ def inner_func(self, *args, **kwargs):
if _has_sid(self) and _is_alive(self):
return func(self, *args, **kwargs)
else:
raise exceptions.NotLoggedInError(f"Login is required to execute function {func}.\nCall login() first!")
raise exceptions.NotLoggedInError(
f"Login is required to execute function {func}.\nCall login() first!"
)

return inner_func

Expand Down
Loading