<jupyter_start><jupyter_text>Attachments pages in confluence  Neccessary imports<jupyter_code>import os
import pandas as pd
from confluenceapi import Confluence, ConfluencePageBuilder<jupyter_output><empty_output><jupyter_text>Setting up our credentials<jupyter_code>conf_server = os.environ['CONFLUENCE_IP'] + ':8090'
credentials = ('admin', '<PASSWORD>')<jupyter_output><empty_output><jupyter_text>Create a confluence and confluencepagebuilder object ready to submit requests<jupyter_code>lc = Confluence(conf_server, credentials)
cp = ConfluencePageBuilder()<jupyter_output><empty_output><jupyter_text>Add an title<jupyter_code>cp.add_title("My title", "h2")<jupyter_output><empty_output><jupyter_text>Add a table of contents<jupyter_code>cp.add_table_of_contents()<jupyter_output><empty_output><jupyter_text>Add a Warning (note, tip, info or warning)<jupyter_code>cp.add_warning("Oh no, the cat is out of the bag!", "note", "cat bag")<jupyter_output><empty_output><jupyter_text>Add a Code block<jupyter_code>cp.add_code_block("import pandas as pd", language="python", theme="midnight")<jupyter_output><empty_output><jupyter_text>Add a Table<jupyter_code>df = pd.DataFrame({'2006': [100, 200, 50], '2007': [300, 400, 200]}, index=['Salmon', 'Herring', 'Shrimp'])
cp.add_table(df)<jupyter_output><empty_output><jupyter_text>Add a Chart<jupyter_code>cp.add_chart(df, 'area')<jupyter_output><empty_output><jupyter_text>Add a new line<jupyter_code>cp.add_new_line()<jupyter_output><empty_output><jupyter_text>Add Custom html<jupyter_code>cp.add_custom_html("The page was last updated by:")<jupyter_output><empty_output><jupyter_text>Add a tag to username<jupyter_code>cp.add_tag_user("admin")<jupyter_output><empty_output><jupyter_text>Add a page link<jupyter_code>cp.add_page_link("Some other page about DS", lc._get_space_key("Data Science", space_name_as_key=False))<jupyter_output><empty_output><jupyter_text>Add pdf preview<jupyter_code>cp.add_pdf_preview("some_pdf_attached_to_this_page.pdf")<jupyter_output><empty_output><jupyter_text>Update our page<jupyter_code>lc.update_page('Page about DS', 'Data Science', cp.render())<jupyter_output><empty_output><jupyter_text>Append content to defined page Restart our template<jupyter_code>cp.restart()<jupyter_output><empty_output><jupyter_text>Get the page contents<jupyter_code>current_content = lc.get_page_contents('Page about DS', 'Data Science')<jupyter_output><empty_output><jupyter_text>Add the current content then add a new line and warning<jupyter_code>cp.add_custom_html(current_content)
cp.add_new_line()
cp.add_warning("We just appended this warning!", "warning")<jupyter_output><empty_output><jupyter_text>Update our page<jupyter_code>lc.update_page('Page about DS', 'Data Science', cp.render())<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12508960573476702, 'fraction_numerical': 0.010752688172043012, 'mean_word_length': 13.536458333333334, 'pattern_counts': {'":': 0, '<': 78, '<?xml version=': 0, '>': 78, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '19', 'dir': 'jupyter-structured-clean-dedup', 'id': '633112', 'license': 'MIT', 'n_tokens_mistral': 1065, 'n_tokens_neox': 1020, 'n_words': 160, 'path': 'examples/ConfluencePageBuilder.ipynb', 'repo_name': 'ghandic/confluenceapi', 'size': '2791'}