[0.2.1] - 2023-10-07
@@ -496,6 +510,10 @@ Changelog
Changelog
+[0.3.0] - 2023-10-07
+
+- Modify min python version to 3.8
+
[0.2.1] - 2023-10-07
- Modify EsaMdier docstrings
diff --git a/index.html b/index.html
index ae8ea24..b468e90 100644
--- a/index.html
+++ b/index.html
@@ -484,7 +484,7 @@ Home
mdfy-esa
-
+
mdfy plugin for esa
diff --git a/search/search_index.json b/search/search_index.json
index 598ae67..f2f3387 100644
--- a/search/search_index.json
+++ b/search/search_index.json
@@ -1 +1 @@
-{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Home","text":""},{"location":"#mdfy-esa","title":"mdfy-esa","text":"mdfy plugin for esa
- Documentation: https://argonism.github.io/mdfy-esa
- GitHub: https://github.com/argonism/mdfy-esa
- PyPI: https://pypi.org/project/mdfy-esa/
- Free software: MIT
"},{"location":"#usage","title":"Usage","text":"The mdfy-esa feature supports uploading of local images and files. With the EsaMdfier, images or files designated with MdImage or MdLink are uploaded automatically. Simply pass the MdImage with the local image path, and voila - it\u2019s done!\"
from mdfy import MdImage, MdLink, MdText\nfrom mdfy_esa import EsaMdfier\n\nesa_team = \"your esa team name\"\npost_fullname = \"post name as you like\"\ncontents = [\n MdText(\"This is a test article.\"),\n MdImage(src=\"examples/test_image.png\"),\n MdLink(url=\"examples/dummy.pdf\"),\n]\n\nmdfier = EsaMdfier(post_fullname=post_fullname, esa_team=esa_team)\ncreated_post_info = mdfier.write(contents=contents)\n\n# created_post_info = {'number': 4418, 'name': 'My Test Article', 'full_name': 'note/me/My Test Article', 'wip': True, 'body_md': 'This is a test article.\\n', 'body_html': '<p data- ...}\n# see esa.io api document for detail\n# https://docs.esa.io/posts/102#POST%20/v1/teams/:team_name/posts\n
You can also update an existing post using its post number!
from mdfy import MdImage, MdLink, MdText\nfrom mdfy_esa import EsaMdfier\n\nesa_team = \"your esa team name\"\npost_number = 4930\ncontents = [\n MdText(\"NEW! This post is updated!\"),\n MdText(\"This is a test article.\"),\n MdImage(src=\"examples/test_image.png\"),\n MdLink(url=\"examples/dummy.pdf\"),\n]\n\nmdfier = EsaMdfier(post_number=post_number, esa_team=esa_team)\nupdated_post_info = mdfier.write(contents=contents)\n
"},{"location":"#features","title":"Features","text":""},{"location":"#credits","title":"Credits","text":"This package was created with Cookiecutter and the waynerv/cookiecutter-pypackage project template.
"},{"location":"changelog/","title":"Changelog","text":""},{"location":"changelog/#changelog","title":"Changelog","text":""},{"location":"changelog/#021---2023-10-07","title":"[0.2.1] - 2023-10-07","text":" - Modify EsaMdier docstrings
"},{"location":"changelog/#020---2023-10-07","title":"[0.2.0] - 2023-10-07","text":" - Add docstrings to stringify_element
"},{"location":"changelog/#011---2023-10-07","title":"[0.1.1] - 2023-10-07","text":""},{"location":"changelog/#010---2023-10-02","title":"[0.1.0] - 2023-10-02","text":""},{"location":"contributing/","title":"Contributing","text":""},{"location":"contributing/#contributing","title":"Contributing","text":"Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
"},{"location":"contributing/#types-of-contributions","title":"Types of Contributions","text":""},{"location":"contributing/#report-bugs","title":"Report Bugs","text":"Report bugs at https://github.com/argonism/mdfy-esa/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
"},{"location":"contributing/#fix-bugs","title":"Fix Bugs","text":"Look through the GitHub issues for bugs. Anything tagged with \"bug\" and \"help wanted\" is open to whoever wants to implement it.
"},{"location":"contributing/#implement-features","title":"Implement Features","text":"Look through the GitHub issues for features. Anything tagged with \"enhancement\" and \"help wanted\" is open to whoever wants to implement it.
"},{"location":"contributing/#write-documentation","title":"Write Documentation","text":"mdfy-esa could always use more documentation, whether as part of the official mdfy-esa docs, in docstrings, or even on the web in blog posts, articles, and such.
"},{"location":"contributing/#submit-feedback","title":"Submit Feedback","text":"The best way to send feedback is to file an issue at https://github.com/argonism/mdfy-esa/issues.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
"},{"location":"contributing/#get-started","title":"Get Started!","text":"Ready to contribute? Here's how to set up mdfy-esa
for local development.
- Fork the
mdfy-esa
repo on GitHub. -
Clone your fork locally
$ git clone git@github.com:your_name_here/mdfy-esa.git\n
-
Ensure poetry is installed.
-
Install dependencies and start your virtualenv:
$ poetry install -E test -E doc -E dev\n
-
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature\n
Now you can make your changes locally.
-
When you're done making changes, check that your changes pass the tests, including testing other Python versions, with tox:
$ poetry run tox\n
-
Commit your changes and push your branch to GitHub:
$ git add .\n$ git commit -m \"Your detailed description of your changes.\"\n$ git push origin name-of-your-bugfix-or-feature\n
-
Submit a pull request through the GitHub website.
"},{"location":"contributing/#pull-request-guidelines","title":"Pull Request Guidelines","text":"Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.md.
- The pull request should work for Python 3.6, 3.7, 3.8 and 3.9. Check https://github.com/argonism/mdfy-esa/actions and make sure that the tests pass for all supported Python versions.
"},{"location":"contributing/#tips","title":"Tips","text":"$ poetry run pytest tests/test_mdfy_esa.py\n
To run a subset of tests.
"},{"location":"contributing/#deploying","title":"Deploying","text":"A reminder for the maintainers on how to deploy. Make sure all your changes are committed (including an entry in CHANGELOG.md). Then run:
$ poetry run bump2version patch # possible: major / minor / patch\n$ git push\n$ git push --tags\n
GitHub Actions will then deploy to PyPI if tests pass.
"},{"location":"installation/","title":"Installation","text":""},{"location":"installation/#installation","title":"Installation","text":""},{"location":"installation/#stable-release","title":"Stable release","text":"To install mdfy-esa, run this command in your terminal:
$ pip install mdfy-esa\n
This is the preferred method to install mdfy-esa, as it will always install the most recent stable release.
If you don't have pip installed, this Python installation guide can guide you through the process.
"},{"location":"installation/#from-source","title":"From source","text":"The source for mdfy-esa can be downloaded from the Github repo.
You can either clone the public repository:
$ git clone git://github.com/argonism/mdfy-esa\n
Or download the tarball:
$ curl -OJL https://github.com/argonism/mdfy-esa/tarball/master\n
Once you have a copy of the source, you can install it with:
$ pip install .\n
"},{"location":"modules/","title":"Modules","text":""},{"location":"modules/#mdfy_esa.mdfy_esa.EsaMdfier","title":"EsaMdfier
","text":" Bases: Mdfier
A class to modify Markdown files and upload images to Esa.
Parameters:
Name Type Description Default post_fullname
Optional[str]
The full name of the post to modify.
None
post_number
Optional[int]
The number of the post to update.
None
esa_team
Optional[str]
The name of the Esa team. Defaults to None. you can set this param or the environment variable ESA_TEAM.
None
Raises:
Type Description ValueError
If esa_team param or the environment variable ESA_TEAM is not set.
Examples:
>>> from mdfy import MdImage, MdLink, MdText\n>>> from mdfy_esa import EsaMdfier\n>>> contents = [\n... MdText(\"This is a test article.\"),\n... MdImage(src=\"example/test_image.png\"),\n... MdLink(url=\"example/dummy.pdf\"),\n... ]\n>>> mdfier = EsaMdfier(post_fullname=\"note/me/My Test Article\", esa_team=\"test_team\")\n>>> mdfier.write(contents=contents)\n
Source code in mdfy_esa/mdfy_esa.py
class EsaMdfier(Mdfier):\n \"\"\"A class to modify Markdown files and upload images to Esa.\n\n Args:\n post_fullname (Optional[str], optional): The full name of the post to modify.\n post_number (Optional[int], optional): The number of the post to update.\n esa_team (Optional[str], optional): The name of the Esa team. Defaults to None.\n you can set this param or the environment variable ESA_TEAM.\n\n Raises:\n ValueError: If esa_team param or the environment variable ESA_TEAM is not set.\n\n Examples:\n >>> from mdfy import MdImage, MdLink, MdText\n >>> from mdfy_esa import EsaMdfier\n >>> contents = [\n ... MdText(\"This is a test article.\"),\n ... MdImage(src=\"example/test_image.png\"),\n ... MdLink(url=\"example/dummy.pdf\"),\n ... ]\n >>> mdfier = EsaMdfier(post_fullname=\"note/me/My Test Article\", esa_team=\"test_team\")\n >>> mdfier.write(contents=contents)\n \"\"\"\n\n def __init__(\n self,\n post_fullname: Optional[str] = None,\n post_number: Optional[int] = None,\n esa_team: Optional[str] = None,\n ) -> None:\n \"\"\"Initializes the EsaMdfier class.\n\n Args:\n post_fullname (Optional[str], optional): The path to the post to modify.\n post_number (Optional[int], optional): The number of the post to update.\n esa_team (Optional[str], optional): The name of the Esa team. Defaults to None.\n \"\"\"\n self.post_fullname = post_fullname\n self.post_number = post_number\n if self.post_fullname is None and self.post_number is None:\n raise ValueError(\"Either post_fullname or post_number must be set. Please set one of them.\")\n\n self.team = os.environ['ESA_TEAM'] if \"ESA_TEAM\" in os.environ else esa_team\n if self.team is None:\n raise ValueError(\"ESA_TEAM is not set. Please set esa_team param or the environment variable ESA_TEAM.\")\n\n self.client = piyo.Client(current_team=self.team)\n\n def stringify_element(self, element: Union[MdElement, str]) -> str:\n \"\"\"Converts the given element to a string.\n\n Args:\n element (Union[MdElement, str]): The element to convert.\n\n Returns:\n str: The converted string.\n \"\"\"\n if isinstance(element, MdImage):\n url = self.client.upload_file(element.src)\n element.src = url\n elif isinstance(element, MdLink):\n parsed_result = urlparse(element.url)\n print(parsed_result)\n if parsed_result.scheme == \"\":\n url = self.client.upload_file(element.url)\n elif parsed_result.scheme == \"file\":\n url = self.client.upload_file(parsed_result.path)\n element.url = url\n return str(element)\n\n def write(\n self,\n contents: Union[List[Union[str, MdElement]], MdElement],\n ) -> Dict[str, Any]:\n \"\"\"post the given Markdown content to esa.io.\n\n Args:\n contents (Union[List[Union[str, MdElement]], MdElement]):\n The Markdown content to write to the file.\n \"\"\"\n\n if not isinstance(contents, list):\n contents = [contents]\n\n markdown = \"\"\n for content in contents:\n content_md = self.stringify_element(content)\n markdown += content_md + \"\\n\"\n\n if self.post_fullname:\n return self.client.create_post({\"post\": {\"name\": self.post_fullname, \"body_md\": markdown}})\n elif self.post_number:\n return self.client.update_post(self.post_number, {\"post\": {\"body_md\": markdown}})\n
"},{"location":"modules/#mdfy_esa.mdfy_esa.EsaMdfier.__init__","title":"__init__(post_fullname=None, post_number=None, esa_team=None)
","text":"Initializes the EsaMdfier class.
Parameters:
Name Type Description Default post_fullname
Optional[str]
The path to the post to modify.
None
post_number
Optional[int]
The number of the post to update.
None
esa_team
Optional[str]
The name of the Esa team. Defaults to None.
None
Source code in mdfy_esa/mdfy_esa.py
def __init__(\n self,\n post_fullname: Optional[str] = None,\n post_number: Optional[int] = None,\n esa_team: Optional[str] = None,\n) -> None:\n \"\"\"Initializes the EsaMdfier class.\n\n Args:\n post_fullname (Optional[str], optional): The path to the post to modify.\n post_number (Optional[int], optional): The number of the post to update.\n esa_team (Optional[str], optional): The name of the Esa team. Defaults to None.\n \"\"\"\n self.post_fullname = post_fullname\n self.post_number = post_number\n if self.post_fullname is None and self.post_number is None:\n raise ValueError(\"Either post_fullname or post_number must be set. Please set one of them.\")\n\n self.team = os.environ['ESA_TEAM'] if \"ESA_TEAM\" in os.environ else esa_team\n if self.team is None:\n raise ValueError(\"ESA_TEAM is not set. Please set esa_team param or the environment variable ESA_TEAM.\")\n\n self.client = piyo.Client(current_team=self.team)\n
"},{"location":"modules/#mdfy_esa.mdfy_esa.EsaMdfier.stringify_element","title":"stringify_element(element)
","text":"Converts the given element to a string.
Parameters:
Name Type Description Default element
Union[MdElement, str]
The element to convert.
required Returns:
Name Type Description str
str
The converted string.
Source code in mdfy_esa/mdfy_esa.py
def stringify_element(self, element: Union[MdElement, str]) -> str:\n \"\"\"Converts the given element to a string.\n\n Args:\n element (Union[MdElement, str]): The element to convert.\n\n Returns:\n str: The converted string.\n \"\"\"\n if isinstance(element, MdImage):\n url = self.client.upload_file(element.src)\n element.src = url\n elif isinstance(element, MdLink):\n parsed_result = urlparse(element.url)\n print(parsed_result)\n if parsed_result.scheme == \"\":\n url = self.client.upload_file(element.url)\n elif parsed_result.scheme == \"file\":\n url = self.client.upload_file(parsed_result.path)\n element.url = url\n return str(element)\n
"},{"location":"modules/#mdfy_esa.mdfy_esa.EsaMdfier.write","title":"write(contents)
","text":"post the given Markdown content to esa.io.
Parameters:
Name Type Description Default contents
Union[List[Union[str, MdElement]], MdElement]
The Markdown content to write to the file.
required Source code in mdfy_esa/mdfy_esa.py
def write(\n self,\n contents: Union[List[Union[str, MdElement]], MdElement],\n) -> Dict[str, Any]:\n \"\"\"post the given Markdown content to esa.io.\n\n Args:\n contents (Union[List[Union[str, MdElement]], MdElement]):\n The Markdown content to write to the file.\n \"\"\"\n\n if not isinstance(contents, list):\n contents = [contents]\n\n markdown = \"\"\n for content in contents:\n content_md = self.stringify_element(content)\n markdown += content_md + \"\\n\"\n\n if self.post_fullname:\n return self.client.create_post({\"post\": {\"name\": self.post_fullname, \"body_md\": markdown}})\n elif self.post_number:\n return self.client.update_post(self.post_number, {\"post\": {\"body_md\": markdown}})\n
"},{"location":"usage/","title":"Usage","text":""},{"location":"usage/#usage","title":"Usage","text":"To use mdfy-esa in a project
import mdfy_esa\nrom mdfy import MdImage, MdLink, MdText\nfrom mdfy_esa import EsaMdfier\ncontents = [\n MdText(\"This is a test article.\"),\n MdImage(src=\"example/test_image.png\"),\n MdLink(url=\"example/dummy.pdf\"),\n]\nmdfier = EsaMdfier(post_fullname=\"note/me/My Test Article\", esa_team=\"test_team\")\nmdfier.write(contents=contents)\n
"}]}
\ No newline at end of file
+{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Home","text":""},{"location":"#mdfy-esa","title":"mdfy-esa","text":"mdfy plugin for esa
- Documentation: https://argonism.github.io/mdfy-esa
- GitHub: https://github.com/argonism/mdfy-esa
- PyPI: https://pypi.org/project/mdfy-esa/
- Free software: MIT
"},{"location":"#usage","title":"Usage","text":"The mdfy-esa feature supports uploading of local images and files. With the EsaMdfier, images or files designated with MdImage or MdLink are uploaded automatically. Simply pass the MdImage with the local image path, and voila - it\u2019s done!\"
from mdfy import MdImage, MdLink, MdText\nfrom mdfy_esa import EsaMdfier\n\nesa_team = \"your esa team name\"\npost_fullname = \"post name as you like\"\ncontents = [\n MdText(\"This is a test article.\"),\n MdImage(src=\"examples/test_image.png\"),\n MdLink(url=\"examples/dummy.pdf\"),\n]\n\nmdfier = EsaMdfier(post_fullname=post_fullname, esa_team=esa_team)\ncreated_post_info = mdfier.write(contents=contents)\n\n# created_post_info = {'number': 4418, 'name': 'My Test Article', 'full_name': 'note/me/My Test Article', 'wip': True, 'body_md': 'This is a test article.\\n', 'body_html': '<p data- ...}\n# see esa.io api document for detail\n# https://docs.esa.io/posts/102#POST%20/v1/teams/:team_name/posts\n
You can also update an existing post using its post number!
from mdfy import MdImage, MdLink, MdText\nfrom mdfy_esa import EsaMdfier\n\nesa_team = \"your esa team name\"\npost_number = 4930\ncontents = [\n MdText(\"NEW! This post is updated!\"),\n MdText(\"This is a test article.\"),\n MdImage(src=\"examples/test_image.png\"),\n MdLink(url=\"examples/dummy.pdf\"),\n]\n\nmdfier = EsaMdfier(post_number=post_number, esa_team=esa_team)\nupdated_post_info = mdfier.write(contents=contents)\n
"},{"location":"#features","title":"Features","text":""},{"location":"#credits","title":"Credits","text":"This package was created with Cookiecutter and the waynerv/cookiecutter-pypackage project template.
"},{"location":"changelog/","title":"Changelog","text":""},{"location":"changelog/#changelog","title":"Changelog","text":""},{"location":"changelog/#030---2023-10-07","title":"[0.3.0] - 2023-10-07","text":" - Modify min python version to 3.8
"},{"location":"changelog/#021---2023-10-07","title":"[0.2.1] - 2023-10-07","text":" - Modify EsaMdier docstrings
"},{"location":"changelog/#020---2023-10-07","title":"[0.2.0] - 2023-10-07","text":" - Add docstrings to stringify_element
"},{"location":"changelog/#011---2023-10-07","title":"[0.1.1] - 2023-10-07","text":""},{"location":"changelog/#010---2023-10-02","title":"[0.1.0] - 2023-10-02","text":""},{"location":"contributing/","title":"Contributing","text":""},{"location":"contributing/#contributing","title":"Contributing","text":"Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
"},{"location":"contributing/#types-of-contributions","title":"Types of Contributions","text":""},{"location":"contributing/#report-bugs","title":"Report Bugs","text":"Report bugs at https://github.com/argonism/mdfy-esa/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
"},{"location":"contributing/#fix-bugs","title":"Fix Bugs","text":"Look through the GitHub issues for bugs. Anything tagged with \"bug\" and \"help wanted\" is open to whoever wants to implement it.
"},{"location":"contributing/#implement-features","title":"Implement Features","text":"Look through the GitHub issues for features. Anything tagged with \"enhancement\" and \"help wanted\" is open to whoever wants to implement it.
"},{"location":"contributing/#write-documentation","title":"Write Documentation","text":"mdfy-esa could always use more documentation, whether as part of the official mdfy-esa docs, in docstrings, or even on the web in blog posts, articles, and such.
"},{"location":"contributing/#submit-feedback","title":"Submit Feedback","text":"The best way to send feedback is to file an issue at https://github.com/argonism/mdfy-esa/issues.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
"},{"location":"contributing/#get-started","title":"Get Started!","text":"Ready to contribute? Here's how to set up mdfy-esa
for local development.
- Fork the
mdfy-esa
repo on GitHub. -
Clone your fork locally
$ git clone git@github.com:your_name_here/mdfy-esa.git\n
-
Ensure poetry is installed.
-
Install dependencies and start your virtualenv:
$ poetry install -E test -E doc -E dev\n
-
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature\n
Now you can make your changes locally.
-
When you're done making changes, check that your changes pass the tests, including testing other Python versions, with tox:
$ poetry run tox\n
-
Commit your changes and push your branch to GitHub:
$ git add .\n$ git commit -m \"Your detailed description of your changes.\"\n$ git push origin name-of-your-bugfix-or-feature\n
-
Submit a pull request through the GitHub website.
"},{"location":"contributing/#pull-request-guidelines","title":"Pull Request Guidelines","text":"Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.md.
- The pull request should work for Python 3.6, 3.7, 3.8 and 3.9. Check https://github.com/argonism/mdfy-esa/actions and make sure that the tests pass for all supported Python versions.
"},{"location":"contributing/#tips","title":"Tips","text":"$ poetry run pytest tests/test_mdfy_esa.py\n
To run a subset of tests.
"},{"location":"contributing/#deploying","title":"Deploying","text":"A reminder for the maintainers on how to deploy. Make sure all your changes are committed (including an entry in CHANGELOG.md). Then run:
$ poetry run bump2version patch # possible: major / minor / patch\n$ git push\n$ git push --tags\n
GitHub Actions will then deploy to PyPI if tests pass.
"},{"location":"installation/","title":"Installation","text":""},{"location":"installation/#installation","title":"Installation","text":""},{"location":"installation/#stable-release","title":"Stable release","text":"To install mdfy-esa, run this command in your terminal:
$ pip install mdfy-esa\n
This is the preferred method to install mdfy-esa, as it will always install the most recent stable release.
If you don't have pip installed, this Python installation guide can guide you through the process.
"},{"location":"installation/#from-source","title":"From source","text":"The source for mdfy-esa can be downloaded from the Github repo.
You can either clone the public repository:
$ git clone git://github.com/argonism/mdfy-esa\n
Or download the tarball:
$ curl -OJL https://github.com/argonism/mdfy-esa/tarball/master\n
Once you have a copy of the source, you can install it with:
$ pip install .\n
"},{"location":"modules/","title":"Modules","text":""},{"location":"modules/#mdfy_esa.mdfy_esa.EsaMdfier","title":"EsaMdfier
","text":" Bases: Mdfier
A class to modify Markdown files and upload images to Esa.
Parameters:
Name Type Description Default post_fullname
Optional[str]
The full name of the post to modify.
None
post_number
Optional[int]
The number of the post to update.
None
esa_team
Optional[str]
The name of the Esa team. Defaults to None. you can set this param or the environment variable ESA_TEAM.
None
Raises:
Type Description ValueError
If esa_team param or the environment variable ESA_TEAM is not set.
Examples:
>>> from mdfy import MdImage, MdLink, MdText\n>>> from mdfy_esa import EsaMdfier\n>>> contents = [\n... MdText(\"This is a test article.\"),\n... MdImage(src=\"example/test_image.png\"),\n... MdLink(url=\"example/dummy.pdf\"),\n... ]\n>>> mdfier = EsaMdfier(post_fullname=\"note/me/My Test Article\", esa_team=\"test_team\")\n>>> mdfier.write(contents=contents)\n
Source code in mdfy_esa/mdfy_esa.py
class EsaMdfier(Mdfier):\n \"\"\"A class to modify Markdown files and upload images to Esa.\n\n Args:\n post_fullname (Optional[str], optional): The full name of the post to modify.\n post_number (Optional[int], optional): The number of the post to update.\n esa_team (Optional[str], optional): The name of the Esa team. Defaults to None.\n you can set this param or the environment variable ESA_TEAM.\n\n Raises:\n ValueError: If esa_team param or the environment variable ESA_TEAM is not set.\n\n Examples:\n >>> from mdfy import MdImage, MdLink, MdText\n >>> from mdfy_esa import EsaMdfier\n >>> contents = [\n ... MdText(\"This is a test article.\"),\n ... MdImage(src=\"example/test_image.png\"),\n ... MdLink(url=\"example/dummy.pdf\"),\n ... ]\n >>> mdfier = EsaMdfier(post_fullname=\"note/me/My Test Article\", esa_team=\"test_team\")\n >>> mdfier.write(contents=contents)\n \"\"\"\n\n def __init__(\n self,\n post_fullname: Optional[str] = None,\n post_number: Optional[int] = None,\n esa_team: Optional[str] = None,\n ) -> None:\n \"\"\"Initializes the EsaMdfier class.\n\n Args:\n post_fullname (Optional[str], optional): The path to the post to modify.\n post_number (Optional[int], optional): The number of the post to update.\n esa_team (Optional[str], optional): The name of the Esa team. Defaults to None.\n \"\"\"\n self.post_fullname = post_fullname\n self.post_number = post_number\n if self.post_fullname is None and self.post_number is None:\n raise ValueError(\"Either post_fullname or post_number must be set. Please set one of them.\")\n\n self.team = os.environ['ESA_TEAM'] if \"ESA_TEAM\" in os.environ else esa_team\n if self.team is None:\n raise ValueError(\"ESA_TEAM is not set. Please set esa_team param or the environment variable ESA_TEAM.\")\n\n self.client = piyo.Client(current_team=self.team)\n\n def stringify_element(self, element: Union[MdElement, str]) -> str:\n \"\"\"Converts the given element to a string.\n\n Args:\n element (Union[MdElement, str]): The element to convert.\n\n Returns:\n str: The converted string.\n \"\"\"\n if isinstance(element, MdImage):\n url = self.client.upload_file(element.src)\n element.src = url\n elif isinstance(element, MdLink):\n parsed_result = urlparse(element.url)\n print(parsed_result)\n if parsed_result.scheme == \"\":\n url = self.client.upload_file(element.url)\n elif parsed_result.scheme == \"file\":\n url = self.client.upload_file(parsed_result.path)\n element.url = url\n return str(element)\n\n def write(\n self,\n contents: Union[List[Union[str, MdElement]], MdElement],\n ) -> Dict[str, Any]:\n \"\"\"post the given Markdown content to esa.io.\n\n Args:\n contents (Union[List[Union[str, MdElement]], MdElement]):\n The Markdown content to write to the file.\n \"\"\"\n\n if not isinstance(contents, list):\n contents = [contents]\n\n markdown = \"\"\n for content in contents:\n content_md = self.stringify_element(content)\n markdown += content_md + \"\\n\"\n\n if self.post_fullname:\n return self.client.create_post({\"post\": {\"name\": self.post_fullname, \"body_md\": markdown}})\n elif self.post_number:\n return self.client.update_post(self.post_number, {\"post\": {\"body_md\": markdown}})\n
"},{"location":"modules/#mdfy_esa.mdfy_esa.EsaMdfier.__init__","title":"__init__(post_fullname=None, post_number=None, esa_team=None)
","text":"Initializes the EsaMdfier class.
Parameters:
Name Type Description Default post_fullname
Optional[str]
The path to the post to modify.
None
post_number
Optional[int]
The number of the post to update.
None
esa_team
Optional[str]
The name of the Esa team. Defaults to None.
None
Source code in mdfy_esa/mdfy_esa.py
def __init__(\n self,\n post_fullname: Optional[str] = None,\n post_number: Optional[int] = None,\n esa_team: Optional[str] = None,\n) -> None:\n \"\"\"Initializes the EsaMdfier class.\n\n Args:\n post_fullname (Optional[str], optional): The path to the post to modify.\n post_number (Optional[int], optional): The number of the post to update.\n esa_team (Optional[str], optional): The name of the Esa team. Defaults to None.\n \"\"\"\n self.post_fullname = post_fullname\n self.post_number = post_number\n if self.post_fullname is None and self.post_number is None:\n raise ValueError(\"Either post_fullname or post_number must be set. Please set one of them.\")\n\n self.team = os.environ['ESA_TEAM'] if \"ESA_TEAM\" in os.environ else esa_team\n if self.team is None:\n raise ValueError(\"ESA_TEAM is not set. Please set esa_team param or the environment variable ESA_TEAM.\")\n\n self.client = piyo.Client(current_team=self.team)\n
"},{"location":"modules/#mdfy_esa.mdfy_esa.EsaMdfier.stringify_element","title":"stringify_element(element)
","text":"Converts the given element to a string.
Parameters:
Name Type Description Default element
Union[MdElement, str]
The element to convert.
required Returns:
Name Type Description str
str
The converted string.
Source code in mdfy_esa/mdfy_esa.py
def stringify_element(self, element: Union[MdElement, str]) -> str:\n \"\"\"Converts the given element to a string.\n\n Args:\n element (Union[MdElement, str]): The element to convert.\n\n Returns:\n str: The converted string.\n \"\"\"\n if isinstance(element, MdImage):\n url = self.client.upload_file(element.src)\n element.src = url\n elif isinstance(element, MdLink):\n parsed_result = urlparse(element.url)\n print(parsed_result)\n if parsed_result.scheme == \"\":\n url = self.client.upload_file(element.url)\n elif parsed_result.scheme == \"file\":\n url = self.client.upload_file(parsed_result.path)\n element.url = url\n return str(element)\n
"},{"location":"modules/#mdfy_esa.mdfy_esa.EsaMdfier.write","title":"write(contents)
","text":"post the given Markdown content to esa.io.
Parameters:
Name Type Description Default contents
Union[List[Union[str, MdElement]], MdElement]
The Markdown content to write to the file.
required Source code in mdfy_esa/mdfy_esa.py
def write(\n self,\n contents: Union[List[Union[str, MdElement]], MdElement],\n) -> Dict[str, Any]:\n \"\"\"post the given Markdown content to esa.io.\n\n Args:\n contents (Union[List[Union[str, MdElement]], MdElement]):\n The Markdown content to write to the file.\n \"\"\"\n\n if not isinstance(contents, list):\n contents = [contents]\n\n markdown = \"\"\n for content in contents:\n content_md = self.stringify_element(content)\n markdown += content_md + \"\\n\"\n\n if self.post_fullname:\n return self.client.create_post({\"post\": {\"name\": self.post_fullname, \"body_md\": markdown}})\n elif self.post_number:\n return self.client.update_post(self.post_number, {\"post\": {\"body_md\": markdown}})\n
"},{"location":"usage/","title":"Usage","text":""},{"location":"usage/#usage","title":"Usage","text":"To use mdfy-esa in a project
import mdfy_esa\nrom mdfy import MdImage, MdLink, MdText\nfrom mdfy_esa import EsaMdfier\ncontents = [\n MdText(\"This is a test article.\"),\n MdImage(src=\"example/test_image.png\"),\n MdLink(url=\"example/dummy.pdf\"),\n]\nmdfier = EsaMdfier(post_fullname=\"note/me/My Test Article\", esa_team=\"test_team\")\nmdfier.write(contents=contents)\n
"}]}
\ No newline at end of file
diff --git a/sitemap.xml.gz b/sitemap.xml.gz
index 149f3a2..96c1ea9 100644
Binary files a/sitemap.xml.gz and b/sitemap.xml.gz differ