Package: sierra
sierraSierra is a Python library to write HTML and CSS in pure Python using the DOM API in a simple yet elegant manner. Take advantage of Python's powerful
functionalities with ease. Loops, variables, functions, libraries - you name it, you have it.Here are a few advantages of using Sierra over other Python libraries that use the DOM API:Out-of-the-box support for all CSS styling attributes for all tagsDisplay a table by simply putting in a CSV fileCreate your own tag functions with absolute ease using@tagand@CmTag. You can decide their behavior and use them within content-managers tooImprovement in the arrangement look of the code and intelligent handling of tags withautoPrettify()- Powered by bs4 and a feature like no otherYou may also use this as a templating engine, although jinja and Django's templating engine is strongly recommended over thisDocumentationCheck out thedocumentation of SierraInstallation and Upgradepip install sierra

pip install --upgrade sierraStarting off is pretty simple and straightforward:fromsierraimport*title('Hello World!')Thetitle()function at the start is mandatory, since it commences the HTML and the CSS file, which is created in the working directory upon execution on the code.You can create custom tag functions with @tag and @CmTag with just three lines of code. Say you want to create a function for <meta>:@tagdefmeta(**kwargs):pass# Using themmeta(name="description",content="This is some description")meta(name="viewport",content="width=device-width",initial_scale=1.0)Underscores are used for hyphens (same applies to CSS) and Python-conficting arguments are prefixed with a double underscore.Using argumenttextinside of a function defined in@tagwill create a tag that opens, enters text, and closes. Something like this:@tagdefscript(**kwargs):passscript(__async="",src="some_src",text="some_text")Is the equivalent of:<scriptasync=""src="some_src">some_text</script>Want to add some JS? Simple enough. Just create a function for the <script> tag with a context manager behavior using@CmTagand you're golden.@CmTagdefscript(**kwargs):pass# Here I'll be replicating the script needed to add Google Analytics to a webpagewithscript(__aync="",src="https://www.googletagmanager.com/gtag/js?id=UAâ€”XXXXXXXX-X"):passwithscript():writeWA('''window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'UAâ€”XXXXXXXX-X');''')This is the equivalent of:<scriptasyncsrc="https://www.googletagmanager.com/gtag/js?id=UAâ€”XXXXXXXX-X"></script><script>window.dataLayer=window.dataLayer||[];functiongtag(){dataLayer.push(arguments);}gtag('js',newDate());gtag('config','UAâ€”XXXXXXXX-X');</script>writeWA()writes text entered into it into the HTML file as it is.You can add fonts usingaddFont()addFont("https://fonts.googleapis.com/css2?family=Roboto&display=swap")Once things at the<head>of the HTML are settled (CSS is automatically linked), begin the body of the HTML withopenBody()# You can add any number of styling arguments to the body within openBody()openBody(background_color='yellowgreen',opacity='0.9')You can createdivandsectiontags this way:withdiv(__class="some_class")asd:p('This is a paragraph!')d.css(background_color="#5886d1")Let's break this down but-by-bit:First, we start adivwith a context manager behavior and give it an attribute__class, which is essentially the tag attributeclass(remember Python-conflicting) arguments are prefixed by a double underscore.p()is a function, as the name suggests, to add a<p>tag. You can give the tag attributes with**kwargs, if you like.p('Hello World!', __class='p_class')is the same as<p class="p_class">Hello World!</p>After the paragraph, there's ad.css(). This adds CSS to theclassmentioned withindiv(). If aclassis mentioned, CSS is added to that class as the first priority. If anidis mentioned, CSS is added to thatidas a second priority. If none of both are mentioned, CSS is just added todiv.The behavior ofdivshown above also applies tosection.You can open a new tag withTag()withTag('some_tag',id='some_id')ast:p('A paragraph in <some_tag>')t.css(color='blue')Although here,.css()behaves differently. It is independent of tag attributes, meaning CSS is added directly to the tag mentioned, which issome_tagTo add CSS to a specific attribute in the tag, usewriteCSS()writeCSS(tag_name,**kwargs)writeCSS("#some_id",color='blue')This adds CSS to thesome_id.You can add a table to the HTML page by inputting in a CSV file this way:withTable()ast:t.get_table("path/to/file.csv")# Add attributes with **kwargs heret.css(border="1px solid black")# Use writeCSS to add CSS to a specific attributeThere are MANY more functionalities to Sierra that you can see from thedocumentationAt the end of all development with Sierra, useautoPrettify()It takes in no arguments, but provides SO much to the code in terms of handling tags and beautifying the look of it.Contact UsEmail:brainstormyourwayin@gmail.comOr you can contact either of us individually if you like. See our individual GitHub profiles for information.GitHubLicenseCopyright 2021 BrainStormYourWayInLicensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.Pandas (pandas)Copyright (c) 2008-2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team.Copyright (c) 2011-2020, Open source contributors.