From b670ce1fec4fb90651f053ee5bf68c7787f2a123 Mon Sep 17 00:00:00 2001 From: Prince2347X Date: Thu, 29 Apr 2021 18:09:03 +0530 Subject: [PATCH 01/29] Script From Links --- pydoodle/jdoodle.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pydoodle/jdoodle.py b/pydoodle/jdoodle.py index c9f0c38..2088bd5 100644 --- a/pydoodle/jdoodle.py +++ b/pydoodle/jdoodle.py @@ -44,16 +44,24 @@ def __init__(self, clientId: str, clientSecret: str): 'smalltalk', 'spidermonkey', 'sql', 'swift', 'tcl', 'unlambda', 'vbn', 'verilog', 'whitespace', 'yabasic'] self.json = {} + + + def _read_link(self, link: str) -> str: + raw_link = f"{link[:link.find('.com')]}.com/raw{link[link.rfind('/'):]}" + r = requests.get(raw_link) + return r.text - def execute(self, script: str, language: str, stdIn: str = None, versionIndex: int = None) -> Output: + def execute(self, script: str, language: str, link: bool = False, stdIn: str = None, versionIndex: int = None) -> Output: """ Executes the provided script. - :parameter script: The script to be executed. + :parameter script: The script to be executed. You can provide link of any code hosting site such as pastebin, hastebin, etc. (You've to set `link` parameter to `True`) :type script: str :parameter language: Language of the script. :type language: str + :parameter link: Tell if a link of any code hosting site(like pastebin, hastebin, etc..) is provided in script parameter. Defaults to `False`. If `True` it takes the script as link and fetch the script from the link. + :type link: bool :parameter stdIn: StdIn of script (If Any), defaults to `None`. In case of multiple inputs, they should be separated by `||` (double pipe). :type stdIn: str, optional :parameter versionIndex: Version Index of language, defaults to `0`. @@ -78,6 +86,9 @@ def execute(self, script: str, language: str, stdIn: str = None, versionIndex: i raise TypeError else: versionIndex = 0 + link = True if script.startswith("https://") else link + if link is not False: + script = _read_link(script) self.json = {"clientId": self.clientID, "clientSecret": self.clientSecret, From 236cc5fea1a56701c19b5c25e0e189e0e27b748b Mon Sep 17 00:00:00 2001 From: Prince2347X Date: Fri, 30 Apr 2021 06:58:40 +0530 Subject: [PATCH 02/29] added textbin support --- pydoodle/jdoodle.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pydoodle/jdoodle.py b/pydoodle/jdoodle.py index 2088bd5..813114d 100644 --- a/pydoodle/jdoodle.py +++ b/pydoodle/jdoodle.py @@ -44,10 +44,15 @@ def __init__(self, clientId: str, clientSecret: str): 'smalltalk', 'spidermonkey', 'sql', 'swift', 'tcl', 'unlambda', 'vbn', 'verilog', 'whitespace', 'yabasic'] self.json = {} - + + def _get_raw_link(self, link: str) -> str: + if "pastebin" in link or "hastebin" in link: + return f"{link[:link.find('.com')]}.com/raw{link[link.rfind('/'):]}" + elif "textbin" in link: + return f"{link[:link.find('.net')]}.net/raw{link[link.rfind('/'):]}" def _read_link(self, link: str) -> str: - raw_link = f"{link[:link.find('.com')]}.com/raw{link[link.rfind('/'):]}" + raw_link = _get_raw_link(link) r = requests.get(raw_link) return r.text From 97f4b89b3c4fd417ddb51c2ba6ec539699dfca4a Mon Sep 17 00:00:00 2001 From: Prince2347X Date: Fri, 30 Apr 2021 13:36:47 +0530 Subject: [PATCH 03/29] fixed some errors --- .gitignore | 1 + .vscode/settings.json | 3 +++ pydoodle/jdoodle.py | 9 ++++----- 3 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore index 273d95c..7d21744 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ *.iml out gen +.vscode # Virtualenv # http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..84a192c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "venv\\Scripts\\python.exe" +} \ No newline at end of file diff --git a/pydoodle/jdoodle.py b/pydoodle/jdoodle.py index 813114d..b5db66a 100644 --- a/pydoodle/jdoodle.py +++ b/pydoodle/jdoodle.py @@ -25,7 +25,6 @@ class Compiler: """ def __init__(self, clientId: str, clientSecret: str): - """""" if not isinstance(clientId, str): raise TypeError elif not isinstance(clientSecret, str): @@ -44,15 +43,15 @@ def __init__(self, clientId: str, clientSecret: str): 'smalltalk', 'spidermonkey', 'sql', 'swift', 'tcl', 'unlambda', 'vbn', 'verilog', 'whitespace', 'yabasic'] self.json = {} - + def _get_raw_link(self, link: str) -> str: if "pastebin" in link or "hastebin" in link: return f"{link[:link.find('.com')]}.com/raw{link[link.rfind('/'):]}" elif "textbin" in link: return f"{link[:link.find('.net')]}.net/raw{link[link.rfind('/'):]}" - + def _read_link(self, link: str) -> str: - raw_link = _get_raw_link(link) + raw_link = self._get_raw_link(link) r = requests.get(raw_link) return r.text @@ -93,7 +92,7 @@ def execute(self, script: str, language: str, link: bool = False, stdIn: str = N versionIndex = 0 link = True if script.startswith("https://") else link if link is not False: - script = _read_link(script) + script = self._read_link(script) self.json = {"clientId": self.clientID, "clientSecret": self.clientSecret, From 29d63764a4db0436753726e1146b4e197b8964e2 Mon Sep 17 00:00:00 2001 From: Prince2347X Date: Fri, 30 Apr 2021 13:54:49 +0530 Subject: [PATCH 04/29] added `LinkNotSupported` error. --- pydoodle/errors.py | 4 ++++ pydoodle/jdoodle.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pydoodle/errors.py b/pydoodle/errors.py index 0620a99..c88c3fe 100644 --- a/pydoodle/errors.py +++ b/pydoodle/errors.py @@ -11,3 +11,7 @@ class UnauthorizedRequest(Exception): class BadRequest(Exception): """Raised when invalid language or versionIndex is provided. """ pass + +class LinkNotSupported(Exception): + """Raised if the provided link isn't supported yet by pydoodle.""" + pass diff --git a/pydoodle/jdoodle.py b/pydoodle/jdoodle.py index b5db66a..f05cafb 100644 --- a/pydoodle/jdoodle.py +++ b/pydoodle/jdoodle.py @@ -1,5 +1,5 @@ import requests -from .errors import UnauthorizedRequest, BadRequest, LanguageNotSupported +from .errors import UnauthorizedRequest, BadRequest, LanguageNotSupported, LinkNotSupported class Output: @@ -49,6 +49,8 @@ def _get_raw_link(self, link: str) -> str: return f"{link[:link.find('.com')]}.com/raw{link[link.rfind('/'):]}" elif "textbin" in link: return f"{link[:link.find('.net')]}.net/raw{link[link.rfind('/'):]}" + else: + raise LinkNotSupported("Not able to fetch script.") def _read_link(self, link: str) -> str: raw_link = self._get_raw_link(link) From 04f6f3274ca0708b006ed812cb851d0089b5f64d Mon Sep 17 00:00:00 2001 From: Prince Raj <68418241+Prince2347X@users.noreply.github.com> Date: Fri, 30 Apr 2021 14:07:39 +0530 Subject: [PATCH 05/29] Delete settings.json --- .vscode/settings.json | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 84a192c..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "python.pythonPath": "venv\\Scripts\\python.exe" -} \ No newline at end of file From 0ab5cc154102c19f5894340c622c2020a602a5b6 Mon Sep 17 00:00:00 2001 From: Prince2347X Date: Sat, 1 May 2021 00:09:40 +0530 Subject: [PATCH 06/29] added pastie support --- pydoodle/jdoodle.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pydoodle/jdoodle.py b/pydoodle/jdoodle.py index f05cafb..af78b1f 100644 --- a/pydoodle/jdoodle.py +++ b/pydoodle/jdoodle.py @@ -49,6 +49,8 @@ def _get_raw_link(self, link: str) -> str: return f"{link[:link.find('.com')]}.com/raw{link[link.rfind('/'):]}" elif "textbin" in link: return f"{link[:link.find('.net')]}.net/raw{link[link.rfind('/'):]}" + elif "pastie" in link: + return f"{link}/raw else: raise LinkNotSupported("Not able to fetch script.") From c125758d19b88aa53cddf676f62db4a4191ced73 Mon Sep 17 00:00:00 2001 From: Prince2347X Date: Sat, 1 May 2021 13:31:13 +0530 Subject: [PATCH 07/29] error solved --- pydoodle/jdoodle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydoodle/jdoodle.py b/pydoodle/jdoodle.py index af78b1f..01fb991 100644 --- a/pydoodle/jdoodle.py +++ b/pydoodle/jdoodle.py @@ -50,7 +50,7 @@ def _get_raw_link(self, link: str) -> str: elif "textbin" in link: return f"{link[:link.find('.net')]}.net/raw{link[link.rfind('/'):]}" elif "pastie" in link: - return f"{link}/raw + return f"{link}/raw" else: raise LinkNotSupported("Not able to fetch script.") From 234598fcb3cf782308d55d798094202942fc8f53 Mon Sep 17 00:00:00 2001 From: Prince2347X Date: Fri, 30 Apr 2021 15:39:40 +0530 Subject: [PATCH 08/29] added theme to docs --- docs/source/conf.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 0a77167..e86dc40 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,4 +1,3 @@ -import re # Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full @@ -13,6 +12,7 @@ # import os import sys +import sphinx_rtd_theme sys.path.insert(0, os.path.abspath('..')) sys.path.insert(0,os.path.abspath('.')) @@ -33,7 +33,8 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - "sphinx.ext.autodoc" + "sphinx.ext.autodoc", + "sphinx_rtd_theme", ] # Add any paths that contain templates here, relative to this directory. @@ -50,8 +51,8 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'alabaster' - +# html_theme = 'alabaster' +html_theme = "sphinx_rtd_theme" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". From c1fe1507f8610e6acba1408f0781505043f955e0 Mon Sep 17 00:00:00 2001 From: Prince2347X Date: Fri, 30 Apr 2021 23:51:14 +0530 Subject: [PATCH 09/29] docs improvement --- docs/source/errors.rst | 11 +++++++++++ docs/source/index.rst | 3 +++ 2 files changed, 14 insertions(+) create mode 100644 docs/source/errors.rst diff --git a/docs/source/errors.rst b/docs/source/errors.rst new file mode 100644 index 0000000..7c1d1ec --- /dev/null +++ b/docs/source/errors.rst @@ -0,0 +1,11 @@ +Errors +======= + +.. autoclass:: pydoodle.LanguageNotSupported + :members: + +.. autoclass:: pydoodle.UnauthorizedRequest + :members: + +.. autoclass:: pydoodle.BadRequest + :members: \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst index 5c2f1f5..1ca5bc7 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -38,9 +38,12 @@ Look how easy it is to use: print(usage, result.output, sep='\n') .. toctree:: + :caption: Pydoodle API + :numbered: :maxdepth: 2 api + errors Indices and tables ================== From 562578721c0aa7570b60ccaceb62186fe794042f Mon Sep 17 00:00:00 2001 From: Prince2347X Date: Fri, 30 Apr 2021 23:59:06 +0530 Subject: [PATCH 10/29] docs improvement --- docs/source/errors.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/errors.rst b/docs/source/errors.rst index 7c1d1ec..94c8ce4 100644 --- a/docs/source/errors.rst +++ b/docs/source/errors.rst @@ -1,11 +1,11 @@ Errors ======= -.. autoclass:: pydoodle.LanguageNotSupported +.. autoclass:: pydoodle.errors.LanguageNotSupported :members: -.. autoclass:: pydoodle.UnauthorizedRequest +.. autoclass:: pydoodle.errors.UnauthorizedRequest :members: -.. autoclass:: pydoodle.BadRequest +.. autoclass:: pydoodle.errors.BadRequest :members: \ No newline at end of file From 557ee04d16fd44aeeac5a90b64286c326646de38 Mon Sep 17 00:00:00 2001 From: Prince2347X Date: Sat, 1 May 2021 12:54:31 +0530 Subject: [PATCH 11/29] dark mode for docs --- docs/source/conf.py | 5 ++++- docs/source/index.rst | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index e86dc40..4d42903 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -35,6 +35,7 @@ extensions = [ "sphinx.ext.autodoc", "sphinx_rtd_theme", + "sphinx_rtd_dark_mode" ] # Add any paths that contain templates here, relative to this directory. @@ -58,4 +59,6 @@ # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] -pygments_style = 'sphinx' +pygments_style = 'friendly' +default_dark_mode = True + diff --git a/docs/source/index.rst b/docs/source/index.rst index 1ca5bc7..ae52afb 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -38,7 +38,7 @@ Look how easy it is to use: print(usage, result.output, sep='\n') .. toctree:: - :caption: Pydoodle API + :caption: Pydoodle :numbered: :maxdepth: 2 From 9c15a00bc71dbf7258f03e5e51b05ba56bf69495 Mon Sep 17 00:00:00 2001 From: Prince2347X Date: Sat, 1 May 2021 13:07:05 +0530 Subject: [PATCH 12/29] dark mode for docs --- docs/source/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/conf.py b/docs/source/conf.py index 4d42903..b122de7 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -13,6 +13,7 @@ import os import sys import sphinx_rtd_theme +import sphinx_rtd_dark_mode sys.path.insert(0, os.path.abspath('..')) sys.path.insert(0,os.path.abspath('.')) From ebea7b8e81e9ea5726463d9bdc28973c8c1d8e3b Mon Sep 17 00:00:00 2001 From: Prince2347X Date: Sat, 1 May 2021 13:14:36 +0530 Subject: [PATCH 13/29] dark mode for docs --- docs/source/requirements_docs.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 docs/source/requirements_docs.txt diff --git a/docs/source/requirements_docs.txt b/docs/source/requirements_docs.txt new file mode 100644 index 0000000..836e28f --- /dev/null +++ b/docs/source/requirements_docs.txt @@ -0,0 +1,2 @@ +sphinx-rtd-dark-mode +sphinx-rtd-theme \ No newline at end of file From fe3f64adadd19288aa7db923eced05c7a1672f4c Mon Sep 17 00:00:00 2001 From: Prince2347X Date: Fri, 30 Apr 2021 13:36:47 +0530 Subject: [PATCH 14/29] fixed some errors --- .vscode/settings.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..84a192c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "venv\\Scripts\\python.exe" +} \ No newline at end of file From e546b72f700d0281cec61c3b79dcff424bd3bdb8 Mon Sep 17 00:00:00 2001 From: Prince2347X Date: Sat, 1 May 2021 14:03:37 +0530 Subject: [PATCH 15/29] Updated docs accordingly --- docs/source/api.rst | 13 +++++++++++++ docs/source/errors.rst | 6 +++++- pydoodle/jdoodle.py | 7 ++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/docs/source/api.rst b/docs/source/api.rst index b1b825b..ab34611 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -6,6 +6,19 @@ Compiler .. autoclass:: pydoodle.Compiler :members: +.. note:: + All types of links aren't yet supported and not to be provided in the ``script`` parameter. + Currently, supported links are: `pastebin.com`_, `hatstebin.com`_, `textbin.net`_ and `pastie.org`_. + Working on to add more of them. Want to suggest? `Start a new discussion`_ on github repo. + + .. Attention:: Only provide links which can be visible by everyone without any kind of password. + + .. _pastebin.com: https://pastebin.com + .. _hatstebin.com: https://hastebin.com + .. _textbin.net: https://textbin.net + .. _pastie.org: https://pastie.org + .. _Start a new discussion: https://github.com/Prince2347X/pydoodle/discussions/new + Output -------- diff --git a/docs/source/errors.rst b/docs/source/errors.rst index 94c8ce4..f266765 100644 --- a/docs/source/errors.rst +++ b/docs/source/errors.rst @@ -8,4 +8,8 @@ Errors :members: .. autoclass:: pydoodle.errors.BadRequest - :members: \ No newline at end of file + :members: + +.. autoclass:: pydoodle.errors.LinkNotSupported + :members: + diff --git a/pydoodle/jdoodle.py b/pydoodle/jdoodle.py index 01fb991..c53f31c 100644 --- a/pydoodle/jdoodle.py +++ b/pydoodle/jdoodle.py @@ -78,9 +78,10 @@ def execute(self, script: str, language: str, link: bool = False, stdIn: str = N :returns: Returns an Output object with all it's attributes. :rtype: Output - :raises: :class:`UnauthorizedRequest`: Raised if either your clientID or clientSecret is invalid. - :raises: :class:`LanguageNotSupported`: Raised if wrong language code is provided. - :raises: :class:`BadRequest`: Raised when invalid language or versionIndex is provided. + :raises: :class:``UnauthorizedRequest``: Raised if either your clientID or clientSecret is invalid. + :raises: :class:``LanguageNotSupported``: Raised if wrong language code is provided. + :raises: :class:``BadRequest``: Raised when invalid language or versionIndex is provided. + :raises: :class:``LinkNotSupported``: Raised if the provided link isn't supported yet by pydoodle. """ if not isinstance(script, str): From 503eda5cfe13a546662108ace747e9aa064e337d Mon Sep 17 00:00:00 2001 From: Prince Raj <68418241+Prince2347X@users.noreply.github.com> Date: Sat, 1 May 2021 22:12:04 +0530 Subject: [PATCH 16/29] minor changes (for docs) --- pydoodle/jdoodle.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pydoodle/jdoodle.py b/pydoodle/jdoodle.py index c53f31c..063f946 100644 --- a/pydoodle/jdoodle.py +++ b/pydoodle/jdoodle.py @@ -78,10 +78,10 @@ def execute(self, script: str, language: str, link: bool = False, stdIn: str = N :returns: Returns an Output object with all it's attributes. :rtype: Output - :raises: :class:``UnauthorizedRequest``: Raised if either your clientID or clientSecret is invalid. - :raises: :class:``LanguageNotSupported``: Raised if wrong language code is provided. - :raises: :class:``BadRequest``: Raised when invalid language or versionIndex is provided. - :raises: :class:``LinkNotSupported``: Raised if the provided link isn't supported yet by pydoodle. + :raises: :class:`UnauthorizedRequest`: Raised if either your clientID or clientSecret is invalid. + :raises: :class:`LanguageNotSupported`: Raised if wrong language code is provided. + :raises: :class:`BadRequest`: Raised when invalid language or versionIndex is provided. + :raises: :class:`LinkNotSupported`: Raised if the provided link isn't supported yet by pydoodle. """ if not isinstance(script, str): From 5a58e8afcadb6cd864f2b08d3d650db23dd3aa16 Mon Sep 17 00:00:00 2001 From: Prince Raj <68418241+Prince2347X@users.noreply.github.com> Date: Sun, 2 May 2021 18:21:55 +0530 Subject: [PATCH 17/29] settings for v1.1.0 --- pydoodle/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydoodle/__init__.py b/pydoodle/__init__.py index 66d1c82..6622e40 100644 --- a/pydoodle/__init__.py +++ b/pydoodle/__init__.py @@ -4,7 +4,7 @@ # METADATA # ############ -__version__ = "v1.0.2" +__version__ = "v1.1.0" __title__ = "pydoodle" __license__ = "MIT" __author__ = "Prince2347X" From 935f177909882af3b70f3361acab1cfaebb92920 Mon Sep 17 00:00:00 2001 From: Prince Raj <68418241+Prince2347X@users.noreply.github.com> Date: Sun, 2 May 2021 18:23:16 +0530 Subject: [PATCH 18/29] Delete .vscode directory --- .vscode/settings.json | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 84a192c..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "python.pythonPath": "venv\\Scripts\\python.exe" -} \ No newline at end of file From 2eef570a893144d66986c75f1d02cb73a74f6031 Mon Sep 17 00:00:00 2001 From: Prince Raj <68418241+Prince2347X@users.noreply.github.com> Date: Sun, 2 May 2021 18:38:40 +0530 Subject: [PATCH 19/29] settings for v1.1.0 --- docs/source/conf.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index b122de7..fa749f9 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -12,11 +12,16 @@ # import os import sys +import re import sphinx_rtd_theme import sphinx_rtd_dark_mode sys.path.insert(0, os.path.abspath('..')) sys.path.insert(0,os.path.abspath('.')) +with open('pydoodle/__init__.py') as f: + version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE).group(1) + + # -- Project information ----------------------------------------------------- @@ -25,7 +30,7 @@ author = 'Prince2347X' # The full version, including alpha/beta/rc tags -release = "1.0.2" +release = version # -- General configuration --------------------------------------------------- From b0ce179040632bc213a51e60ca5abefa588035ed Mon Sep 17 00:00:00 2001 From: Prince Raj <68418241+Prince2347X@users.noreply.github.com> Date: Mon, 3 May 2021 00:11:50 +0530 Subject: [PATCH 20/29] Create example_links.py --- examples/example_links.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 examples/example_links.py diff --git a/examples/example_links.py b/examples/example_links.py new file mode 100644 index 0000000..764e50a --- /dev/null +++ b/examples/example_links.py @@ -0,0 +1,7 @@ +import pydoodle + +c = pydoodle.Compiler(clientId="client-id", + clientSecret="client-secret") # which you'll get from https://jdoodle.com/compiler-api +result = c.execute(script="https://pastebin.com/vJFXrKX3", language="python3", link=True) #NOTE: I've set the `link` parameter to True because I'm providing link in script parameter. +print(result.output) + From f6bc04242cb095b5c29303a7a23a344e73c6da5a Mon Sep 17 00:00:00 2001 From: Prince Raj <68418241+Prince2347X@users.noreply.github.com> Date: Mon, 3 May 2021 00:14:41 +0530 Subject: [PATCH 21/29] added example_links.py --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 14f3bf2..7aa4049 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ pip install pydoodle ``` - [example.py](https://github.com/Prince2347X/pydoodle/blob/master/examples/example.py) -> Basic example on how to use! - [example_stdIn.py](https://github.com/Prince2347X/pydoodle/blob/master/examples/example_stdIn.py) -> Example on how to use stdIn (inputs). + - [example_links.py](https://github.com/Prince2347X/pydoodle/blob/master/examples/example_links.py) -> Example on how to use links as script. ### Misc From 59c1f22b7fbde695f0550f8d0acd0d321efa2554 Mon Sep 17 00:00:00 2001 From: Prince Raj <68418241+Prince2347X@users.noreply.github.com> Date: Mon, 3 May 2021 00:21:46 +0530 Subject: [PATCH 22/29] Update api.rst --- docs/source/api.rst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/source/api.rst b/docs/source/api.rst index ab34611..86323ac 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -11,7 +11,7 @@ Compiler Currently, supported links are: `pastebin.com`_, `hatstebin.com`_, `textbin.net`_ and `pastie.org`_. Working on to add more of them. Want to suggest? `Start a new discussion`_ on github repo. - .. Attention:: Only provide links which can be visible by everyone without any kind of password. +.. Attention:: Only provide links which can be visible by everyone without any kind of password. .. _pastebin.com: https://pastebin.com .. _hatstebin.com: https://hastebin.com @@ -24,6 +24,14 @@ Output .. autoclass:: pydoodle.jdoodle.Output :members: + .. confval:: output + The output of the script. + .. confval:: statusCode + The status code of the executed program. + .. confval:: memory + The memory used to execut the script. + .. confval:: cpuTime + Time taken to execut the script (in seconds). .. _here: https://docs.jdoodle.com/compiler-api/compiler-api#what-languages-and-versions-supported From a9164a12c0a7fc2bff07b82560d39f753b51f378 Mon Sep 17 00:00:00 2001 From: Prince Raj <68418241+Prince2347X@users.noreply.github.com> Date: Mon, 3 May 2021 00:26:03 +0530 Subject: [PATCH 23/29] Update conf.py --- docs/source/conf.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index fa749f9..ebcb81d 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -12,14 +12,12 @@ # import os import sys -import re import sphinx_rtd_theme import sphinx_rtd_dark_mode sys.path.insert(0, os.path.abspath('..')) sys.path.insert(0,os.path.abspath('.')) -with open('pydoodle/__init__.py') as f: - version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE).group(1) +version = "v1.1.0" From e3d1462c43e5d9946808b6e60dc066b69828f234 Mon Sep 17 00:00:00 2001 From: Prince Raj <68418241+Prince2347X@users.noreply.github.com> Date: Mon, 3 May 2021 00:32:03 +0530 Subject: [PATCH 24/29] Update api.rst --- docs/source/api.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/source/api.rst b/docs/source/api.rst index 86323ac..d8d8643 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -24,14 +24,14 @@ Output .. autoclass:: pydoodle.jdoodle.Output :members: - .. confval:: output - The output of the script. - .. confval:: statusCode - The status code of the executed program. - .. confval:: memory - The memory used to execut the script. - .. confval:: cpuTime - Time taken to execut the script (in seconds). +.. confval:: output + The output of the script. +.. confval:: statusCode + The status code of the executed program. +.. confval:: memory + The memory used to execut the script. +.. confval:: cpuTime + Time taken to execut the script (in seconds). .. _here: https://docs.jdoodle.com/compiler-api/compiler-api#what-languages-and-versions-supported From 7fb1d6afac61b9cbd588a2c877e0215310294ba2 Mon Sep 17 00:00:00 2001 From: Prince Raj <68418241+Prince2347X@users.noreply.github.com> Date: Mon, 3 May 2021 00:42:02 +0530 Subject: [PATCH 25/29] Added confval --- docs/source/conf.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/source/conf.py b/docs/source/conf.py index ebcb81d..401e998 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -66,3 +66,29 @@ pygments_style = 'friendly' default_dark_mode = True +# Extensions to theme docs +def setup(app): + from sphinx.domains.python import PyField + from sphinx.util.docfields import Field + + app.add_object_type( + 'confval', + 'confval', + objname='configuration value', + indextemplate='pair: %s; configuration value', + doc_field_types=[ + PyField( + 'type', + label=_('Type'), + has_arg=False, + names=('type',), + bodyrolename='class' + ), + Field( + 'default', + label=_('Default'), + has_arg=False, + names=('default',), + ), + ] + ) From 9ee3e75122ae905092cfe360a48a1d2806e8b5d4 Mon Sep 17 00:00:00 2001 From: Prince Raj <68418241+Prince2347X@users.noreply.github.com> Date: Mon, 3 May 2021 00:44:30 +0530 Subject: [PATCH 26/29] Fixed imports --- docs/source/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/conf.py b/docs/source/conf.py index 401e998..4931ca3 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,6 +14,7 @@ import sys import sphinx_rtd_theme import sphinx_rtd_dark_mode +from sphinx.locale import _ sys.path.insert(0, os.path.abspath('..')) sys.path.insert(0,os.path.abspath('.')) From b1e917adbc5b710976c205c6439229833eefed2b Mon Sep 17 00:00:00 2001 From: Prince Raj <68418241+Prince2347X@users.noreply.github.com> Date: Mon, 3 May 2021 00:49:57 +0530 Subject: [PATCH 27/29] finally --- docs/source/api.rst | 8 -------- 1 file changed, 8 deletions(-) diff --git a/docs/source/api.rst b/docs/source/api.rst index d8d8643..500c799 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -24,14 +24,6 @@ Output .. autoclass:: pydoodle.jdoodle.Output :members: -.. confval:: output - The output of the script. -.. confval:: statusCode - The status code of the executed program. -.. confval:: memory - The memory used to execut the script. -.. confval:: cpuTime - Time taken to execut the script (in seconds). .. _here: https://docs.jdoodle.com/compiler-api/compiler-api#what-languages-and-versions-supported From c720ea97034d8f6ba59ecebef03ad7182a241c7c Mon Sep 17 00:00:00 2001 From: Prince Raj <68418241+Prince2347X@users.noreply.github.com> Date: Mon, 3 May 2021 00:54:49 +0530 Subject: [PATCH 28/29] cleanup --- docs/source/conf.py | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 4931ca3..8598d51 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,7 +14,6 @@ import sys import sphinx_rtd_theme import sphinx_rtd_dark_mode -from sphinx.locale import _ sys.path.insert(0, os.path.abspath('..')) sys.path.insert(0,os.path.abspath('.')) @@ -66,30 +65,3 @@ pygments_style = 'friendly' default_dark_mode = True - -# Extensions to theme docs -def setup(app): - from sphinx.domains.python import PyField - from sphinx.util.docfields import Field - - app.add_object_type( - 'confval', - 'confval', - objname='configuration value', - indextemplate='pair: %s; configuration value', - doc_field_types=[ - PyField( - 'type', - label=_('Type'), - has_arg=False, - names=('type',), - bodyrolename='class' - ), - Field( - 'default', - label=_('Default'), - has_arg=False, - names=('default',), - ), - ] - ) From 38ac5a650bb982b4f9cd49c33792ace96fe4446a Mon Sep 17 00:00:00 2001 From: Prince Raj <68418241+Prince2347X@users.noreply.github.com> Date: Mon, 3 May 2021 01:03:56 +0530 Subject: [PATCH 29/29] =?UTF-8?q?conflict=201=20=E2=98=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/conf.py b/docs/source/conf.py index 8598d51..ebcb81d 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -65,3 +65,4 @@ pygments_style = 'friendly' default_dark_mode = True +