summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2023-05-15 07:27:36 +0000
committerCoprDistGit <infra@openeuler.org>2023-05-15 07:27:36 +0000
commit726d05bb5811fa548fbe3bb7a77515772d56daf2 (patch)
tree0975f1fbf3fdb9f2bd4a791a092e00b2f7eece57
parentd6ad5cbe43991498b5d1edcade042374e5bb96f8 (diff)
automatic import of python-htbuilder
-rw-r--r--.gitignore1
-rw-r--r--python-htbuilder.spec819
-rw-r--r--sources1
3 files changed, 821 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..9976a46 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/htbuilder-0.6.1.tar.gz
diff --git a/python-htbuilder.spec b/python-htbuilder.spec
new file mode 100644
index 0000000..4be5014
--- /dev/null
+++ b/python-htbuilder.spec
@@ -0,0 +1,819 @@
+%global _empty_manifest_terminate_build 0
+Name: python-htbuilder
+Version: 0.6.1
+Release: 1
+Summary: A purely-functional HTML builder for Python. Think JSX rather than templates.
+License: Apache 2
+URL: https://github.com/tvst/htbuilder
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/3d/40/2502c8f1ddc45a080fc9048a0e426d5389fa1b2ab71fbe60d2d9a25cadca/htbuilder-0.6.1.tar.gz
+BuildArch: noarch
+
+
+%description
+# htbuilder — tiny HTML string builder for Python
+
+htbuilder lets you build HTML strings using a purely functional syntax in Python.
+Why use templating languages when you can just use functions?
+
+(PS: If you like this, check out [jsbuild](https://github.com/tvst/jsbuild) which
+lets you build JavaScript strings by simply annotating Python functions!)
+
+## Installation
+
+Just PIP it!
+
+```py
+pip install htbuilder
+```
+
+## Usage
+
+Just import tags like `div` with `from htbuilder import div`, then call them:
+
+```py
+# Import any tag you want from htbuilder, and it just works!
+# (This syntax requires Python 3.7+. See below for an alternate syntax)
+from htbuilder import div
+
+dom = div('Hello world!')
+```
+
+Then you can get the string output by calling `str()` on it:
+
+```py
+str(dom)
+# Returns '<div>Hello world!</div>'
+```
+
+...which means you can also just `print()` to see it in the terminal:
+
+```py
+print(dom)
+# Prints '<div>Hello world!</div>'
+```
+
+To specify attributes, call the tag builder with keyword args:
+
+```py
+print(
+ div(id='sidebar', foo='bar')
+)
+# Prints '<div id="sidebar" foo="bar"></div>'
+```
+
+To specify both attributes and children, first specify the attributes using
+keyword args, then pass the children afterwards **inside a new
+set of parentheses**:
+
+```py
+print(
+ div(id='sidebar', foo='bar')(
+ "Hello world!"
+ )
+)
+# Prints '<div id="sidebar" foo="bar">Hello world!</div>'
+```
+
+This is required because Python doesn't allow you to pass keyword arguments
+_before_ you pass normal arguments.
+
+
+## Multiple children
+
+Want to output multiple children? Just pass them all as arguments:
+
+```py
+from htbuilder import div, ul, li, img
+
+dom = (
+ div(id='container')(
+ ul(_class='greetings')(
+ li('hello'),
+ li('hi'),
+ li('whattup'),
+ )
+ )
+)
+
+print(dom)
+
+# Prints this (but without added spacing):
+# <div id="container">
+# <ul class="greetings">
+# <li>hello</li>
+# <li>hi</li>
+# <li>whattup</li>
+# </ul>
+# </div>
+```
+
+## Programmatically add children
+
+You can also pass any iterable to specify multiple children, which means you can
+simply use things like generator expressions for great awesome:
+
+```py
+from htbuilder import div, ul, li, img
+
+image_paths = [
+ 'http://myimages.com/foo1.jpg',
+ 'http://myimages.com/foo2.jpg',
+ 'http://myimages.com/foo3.jpg',
+]
+
+dom = (
+ div(id='container')(
+ ul(_class='image-list')(
+ li(img(src=image_path, _class='large-image'))
+ for image_path in image_paths
+ )
+ )
+)
+
+print(dom)
+# Prints:
+# <div id="container">
+# <ul class="image-list">
+# <li><img src="http://myimages.com/foo1.jpg" class="large-image"/></li>
+# <li><img src="http://myimages.com/foo2.jpg" class="large-image"/></li>
+# <li><img src="http://myimages.com/foo3.jpg" class="large-image"/></li>
+# </ul>
+# </div>
+```
+
+## Conditionally add elements
+
+And because it's just Python, you can use an if/else expression to conditionally
+insert elements:
+
+```py
+use_bold = True
+
+dom = (
+ div(
+ b("bold text")
+ if use_bold else
+ "normal text"
+ )
+)
+
+print(dom)
+# Prints: <div><b>bold text</b></div>
+```
+
+## Styling
+
+We provide helpers to write styles without having to pass huge style strings as
+arguments. Instead, just use handy builders like `styles()`, `classes()`,
+`fonts()`, along with helpers you can import from the `units` and `funcs`
+modules.
+
+```py
+# styles, classes, and fonts are special imports to help build attribute strings.
+from htbuilder import div, styles, classes, fonts
+
+# You can import anything from .units and .funcs to make it easier to specify
+# units like "%" and "px", as well as functions like "rgba()" and "rgba()".
+from htbuilder.units import percent, px
+from htbuilder.funcs import rgba, rgb
+
+bottom_margin = 10
+is_big = True
+
+dom = (
+ div(
+ _class=classes('btn', big=is_big)
+ style=styles(
+ color='black',
+ font_family=fonts('Comic Sans', 'sans-serif'),
+ margin=px(0, 0, bottom_margin, 0),
+ padding=(px(10), percent(5))
+ box_shadow=[
+ (0, 0, px(10), rgba(0, 0, 0, 0.1)),
+ (0, 0, '2px', rgb(0, 0, 0)),
+ ],
+ )
+ )
+)
+
+# Prints:
+# <div
+# class="btn big"
+# style="
+# color: black;
+# font-family: "Comic Sans", "sans-serif";
+# margin: 0 0 10px 0;
+# padding: 10px 5%;
+# box-shadow: 0 0 10px rgba(0, 0, 0, 0.1), 0 0 2px rgb(0, 0, 0);
+# "></div>
+```
+
+
+## Underscores are magic
+
+### Use underscores instead of dashes
+
+Like most popular languages, Python doesn't support dashes in identifiers. So if you want to build
+an element that includes dashes in the tag name or attributes, like `<my-element foo-bar="baz">`, you can
+do so by using underscores instead:
+
+```py
+from htbuilder import my_element
+
+dom = my_element(foo_bar="baz")
+
+print(dom)
+# Prints:
+# <my-element foo-bar="baz"></my-element>
+```
+
+### Prefix with underscore to avoid reserved words
+
+The word `class` is reserved in Python, so if you want to set an element's `class` attribute you
+should prepend it with an underscore like this:
+
+```py
+dom = div(_class="myclass")
+
+print(dom)
+# Prints:
+# <div class="myclass"></div>
+```
+
+This works because underscores preceding or following any identifier are automatically stripped away
+for you.
+
+
+## Working with Python &lt; 3.7
+
+If using Python &lt; 3.7, the import should look like this instead:
+
+```py
+from htbuilder import H
+
+div = H.div
+ul = H.ul
+li = H.li
+img = H.img
+# ...etc
+```
+
+
+
+
+%package -n python3-htbuilder
+Summary: A purely-functional HTML builder for Python. Think JSX rather than templates.
+Provides: python-htbuilder
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-htbuilder
+# htbuilder — tiny HTML string builder for Python
+
+htbuilder lets you build HTML strings using a purely functional syntax in Python.
+Why use templating languages when you can just use functions?
+
+(PS: If you like this, check out [jsbuild](https://github.com/tvst/jsbuild) which
+lets you build JavaScript strings by simply annotating Python functions!)
+
+## Installation
+
+Just PIP it!
+
+```py
+pip install htbuilder
+```
+
+## Usage
+
+Just import tags like `div` with `from htbuilder import div`, then call them:
+
+```py
+# Import any tag you want from htbuilder, and it just works!
+# (This syntax requires Python 3.7+. See below for an alternate syntax)
+from htbuilder import div
+
+dom = div('Hello world!')
+```
+
+Then you can get the string output by calling `str()` on it:
+
+```py
+str(dom)
+# Returns '<div>Hello world!</div>'
+```
+
+...which means you can also just `print()` to see it in the terminal:
+
+```py
+print(dom)
+# Prints '<div>Hello world!</div>'
+```
+
+To specify attributes, call the tag builder with keyword args:
+
+```py
+print(
+ div(id='sidebar', foo='bar')
+)
+# Prints '<div id="sidebar" foo="bar"></div>'
+```
+
+To specify both attributes and children, first specify the attributes using
+keyword args, then pass the children afterwards **inside a new
+set of parentheses**:
+
+```py
+print(
+ div(id='sidebar', foo='bar')(
+ "Hello world!"
+ )
+)
+# Prints '<div id="sidebar" foo="bar">Hello world!</div>'
+```
+
+This is required because Python doesn't allow you to pass keyword arguments
+_before_ you pass normal arguments.
+
+
+## Multiple children
+
+Want to output multiple children? Just pass them all as arguments:
+
+```py
+from htbuilder import div, ul, li, img
+
+dom = (
+ div(id='container')(
+ ul(_class='greetings')(
+ li('hello'),
+ li('hi'),
+ li('whattup'),
+ )
+ )
+)
+
+print(dom)
+
+# Prints this (but without added spacing):
+# <div id="container">
+# <ul class="greetings">
+# <li>hello</li>
+# <li>hi</li>
+# <li>whattup</li>
+# </ul>
+# </div>
+```
+
+## Programmatically add children
+
+You can also pass any iterable to specify multiple children, which means you can
+simply use things like generator expressions for great awesome:
+
+```py
+from htbuilder import div, ul, li, img
+
+image_paths = [
+ 'http://myimages.com/foo1.jpg',
+ 'http://myimages.com/foo2.jpg',
+ 'http://myimages.com/foo3.jpg',
+]
+
+dom = (
+ div(id='container')(
+ ul(_class='image-list')(
+ li(img(src=image_path, _class='large-image'))
+ for image_path in image_paths
+ )
+ )
+)
+
+print(dom)
+# Prints:
+# <div id="container">
+# <ul class="image-list">
+# <li><img src="http://myimages.com/foo1.jpg" class="large-image"/></li>
+# <li><img src="http://myimages.com/foo2.jpg" class="large-image"/></li>
+# <li><img src="http://myimages.com/foo3.jpg" class="large-image"/></li>
+# </ul>
+# </div>
+```
+
+## Conditionally add elements
+
+And because it's just Python, you can use an if/else expression to conditionally
+insert elements:
+
+```py
+use_bold = True
+
+dom = (
+ div(
+ b("bold text")
+ if use_bold else
+ "normal text"
+ )
+)
+
+print(dom)
+# Prints: <div><b>bold text</b></div>
+```
+
+## Styling
+
+We provide helpers to write styles without having to pass huge style strings as
+arguments. Instead, just use handy builders like `styles()`, `classes()`,
+`fonts()`, along with helpers you can import from the `units` and `funcs`
+modules.
+
+```py
+# styles, classes, and fonts are special imports to help build attribute strings.
+from htbuilder import div, styles, classes, fonts
+
+# You can import anything from .units and .funcs to make it easier to specify
+# units like "%" and "px", as well as functions like "rgba()" and "rgba()".
+from htbuilder.units import percent, px
+from htbuilder.funcs import rgba, rgb
+
+bottom_margin = 10
+is_big = True
+
+dom = (
+ div(
+ _class=classes('btn', big=is_big)
+ style=styles(
+ color='black',
+ font_family=fonts('Comic Sans', 'sans-serif'),
+ margin=px(0, 0, bottom_margin, 0),
+ padding=(px(10), percent(5))
+ box_shadow=[
+ (0, 0, px(10), rgba(0, 0, 0, 0.1)),
+ (0, 0, '2px', rgb(0, 0, 0)),
+ ],
+ )
+ )
+)
+
+# Prints:
+# <div
+# class="btn big"
+# style="
+# color: black;
+# font-family: "Comic Sans", "sans-serif";
+# margin: 0 0 10px 0;
+# padding: 10px 5%;
+# box-shadow: 0 0 10px rgba(0, 0, 0, 0.1), 0 0 2px rgb(0, 0, 0);
+# "></div>
+```
+
+
+## Underscores are magic
+
+### Use underscores instead of dashes
+
+Like most popular languages, Python doesn't support dashes in identifiers. So if you want to build
+an element that includes dashes in the tag name or attributes, like `<my-element foo-bar="baz">`, you can
+do so by using underscores instead:
+
+```py
+from htbuilder import my_element
+
+dom = my_element(foo_bar="baz")
+
+print(dom)
+# Prints:
+# <my-element foo-bar="baz"></my-element>
+```
+
+### Prefix with underscore to avoid reserved words
+
+The word `class` is reserved in Python, so if you want to set an element's `class` attribute you
+should prepend it with an underscore like this:
+
+```py
+dom = div(_class="myclass")
+
+print(dom)
+# Prints:
+# <div class="myclass"></div>
+```
+
+This works because underscores preceding or following any identifier are automatically stripped away
+for you.
+
+
+## Working with Python &lt; 3.7
+
+If using Python &lt; 3.7, the import should look like this instead:
+
+```py
+from htbuilder import H
+
+div = H.div
+ul = H.ul
+li = H.li
+img = H.img
+# ...etc
+```
+
+
+
+
+%package help
+Summary: Development documents and examples for htbuilder
+Provides: python3-htbuilder-doc
+%description help
+# htbuilder — tiny HTML string builder for Python
+
+htbuilder lets you build HTML strings using a purely functional syntax in Python.
+Why use templating languages when you can just use functions?
+
+(PS: If you like this, check out [jsbuild](https://github.com/tvst/jsbuild) which
+lets you build JavaScript strings by simply annotating Python functions!)
+
+## Installation
+
+Just PIP it!
+
+```py
+pip install htbuilder
+```
+
+## Usage
+
+Just import tags like `div` with `from htbuilder import div`, then call them:
+
+```py
+# Import any tag you want from htbuilder, and it just works!
+# (This syntax requires Python 3.7+. See below for an alternate syntax)
+from htbuilder import div
+
+dom = div('Hello world!')
+```
+
+Then you can get the string output by calling `str()` on it:
+
+```py
+str(dom)
+# Returns '<div>Hello world!</div>'
+```
+
+...which means you can also just `print()` to see it in the terminal:
+
+```py
+print(dom)
+# Prints '<div>Hello world!</div>'
+```
+
+To specify attributes, call the tag builder with keyword args:
+
+```py
+print(
+ div(id='sidebar', foo='bar')
+)
+# Prints '<div id="sidebar" foo="bar"></div>'
+```
+
+To specify both attributes and children, first specify the attributes using
+keyword args, then pass the children afterwards **inside a new
+set of parentheses**:
+
+```py
+print(
+ div(id='sidebar', foo='bar')(
+ "Hello world!"
+ )
+)
+# Prints '<div id="sidebar" foo="bar">Hello world!</div>'
+```
+
+This is required because Python doesn't allow you to pass keyword arguments
+_before_ you pass normal arguments.
+
+
+## Multiple children
+
+Want to output multiple children? Just pass them all as arguments:
+
+```py
+from htbuilder import div, ul, li, img
+
+dom = (
+ div(id='container')(
+ ul(_class='greetings')(
+ li('hello'),
+ li('hi'),
+ li('whattup'),
+ )
+ )
+)
+
+print(dom)
+
+# Prints this (but without added spacing):
+# <div id="container">
+# <ul class="greetings">
+# <li>hello</li>
+# <li>hi</li>
+# <li>whattup</li>
+# </ul>
+# </div>
+```
+
+## Programmatically add children
+
+You can also pass any iterable to specify multiple children, which means you can
+simply use things like generator expressions for great awesome:
+
+```py
+from htbuilder import div, ul, li, img
+
+image_paths = [
+ 'http://myimages.com/foo1.jpg',
+ 'http://myimages.com/foo2.jpg',
+ 'http://myimages.com/foo3.jpg',
+]
+
+dom = (
+ div(id='container')(
+ ul(_class='image-list')(
+ li(img(src=image_path, _class='large-image'))
+ for image_path in image_paths
+ )
+ )
+)
+
+print(dom)
+# Prints:
+# <div id="container">
+# <ul class="image-list">
+# <li><img src="http://myimages.com/foo1.jpg" class="large-image"/></li>
+# <li><img src="http://myimages.com/foo2.jpg" class="large-image"/></li>
+# <li><img src="http://myimages.com/foo3.jpg" class="large-image"/></li>
+# </ul>
+# </div>
+```
+
+## Conditionally add elements
+
+And because it's just Python, you can use an if/else expression to conditionally
+insert elements:
+
+```py
+use_bold = True
+
+dom = (
+ div(
+ b("bold text")
+ if use_bold else
+ "normal text"
+ )
+)
+
+print(dom)
+# Prints: <div><b>bold text</b></div>
+```
+
+## Styling
+
+We provide helpers to write styles without having to pass huge style strings as
+arguments. Instead, just use handy builders like `styles()`, `classes()`,
+`fonts()`, along with helpers you can import from the `units` and `funcs`
+modules.
+
+```py
+# styles, classes, and fonts are special imports to help build attribute strings.
+from htbuilder import div, styles, classes, fonts
+
+# You can import anything from .units and .funcs to make it easier to specify
+# units like "%" and "px", as well as functions like "rgba()" and "rgba()".
+from htbuilder.units import percent, px
+from htbuilder.funcs import rgba, rgb
+
+bottom_margin = 10
+is_big = True
+
+dom = (
+ div(
+ _class=classes('btn', big=is_big)
+ style=styles(
+ color='black',
+ font_family=fonts('Comic Sans', 'sans-serif'),
+ margin=px(0, 0, bottom_margin, 0),
+ padding=(px(10), percent(5))
+ box_shadow=[
+ (0, 0, px(10), rgba(0, 0, 0, 0.1)),
+ (0, 0, '2px', rgb(0, 0, 0)),
+ ],
+ )
+ )
+)
+
+# Prints:
+# <div
+# class="btn big"
+# style="
+# color: black;
+# font-family: "Comic Sans", "sans-serif";
+# margin: 0 0 10px 0;
+# padding: 10px 5%;
+# box-shadow: 0 0 10px rgba(0, 0, 0, 0.1), 0 0 2px rgb(0, 0, 0);
+# "></div>
+```
+
+
+## Underscores are magic
+
+### Use underscores instead of dashes
+
+Like most popular languages, Python doesn't support dashes in identifiers. So if you want to build
+an element that includes dashes in the tag name or attributes, like `<my-element foo-bar="baz">`, you can
+do so by using underscores instead:
+
+```py
+from htbuilder import my_element
+
+dom = my_element(foo_bar="baz")
+
+print(dom)
+# Prints:
+# <my-element foo-bar="baz"></my-element>
+```
+
+### Prefix with underscore to avoid reserved words
+
+The word `class` is reserved in Python, so if you want to set an element's `class` attribute you
+should prepend it with an underscore like this:
+
+```py
+dom = div(_class="myclass")
+
+print(dom)
+# Prints:
+# <div class="myclass"></div>
+```
+
+This works because underscores preceding or following any identifier are automatically stripped away
+for you.
+
+
+## Working with Python &lt; 3.7
+
+If using Python &lt; 3.7, the import should look like this instead:
+
+```py
+from htbuilder import H
+
+div = H.div
+ul = H.ul
+li = H.li
+img = H.img
+# ...etc
+```
+
+
+
+
+%prep
+%autosetup -n htbuilder-0.6.1
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-htbuilder -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Mon May 15 2023 Python_Bot <Python_Bot@openeuler.org> - 0.6.1-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..02d587e
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+035a34a95f94e66432cf26f74590d383 htbuilder-0.6.1.tar.gz