Index: html/bind.html ================================================================== --- html/bind.html +++ html/bind.html @@ -99,11 +99,11 @@ </table> <p>Module should be a package, as in a directory and init <code>plugins/__init__.py</code>. Ideally this module was already imported in main. But parameter may be a string.</p> <p>This could be invoked multiple times for the package name to append further path= arguments (=./contrib/, =/usr/share/app/extenstions/, or a .pyz). Which -is functionally identical to delcaring <code>__path__</code> in the <code>package/__init__.py</code>.</p></div> +is functionally identical to declaring <code>__path__</code> in the <code>package/__init__.py</code>.</p></div> </dd> <dt id="pluginconf.bind.defaults"><code class="name flex"> <span>def <span class="ident">defaults</span></span>(<span>conf)</span> </code></dt> <dd> Index: html/setup.html ================================================================== --- html/setup.html +++ html/setup.html @@ -29,22 +29,10 @@ <section> </section> <section> <h2 class="section-title" id="header-functions">Functions</h2> <dl> -<dt id="pluginconf.setup.get_readme"><code class="name flex"> -<span>def <span class="ident">get_readme</span></span>(<span>)</span> -</code></dt> -<dd> -<div class="desc"><p>get README.md contents</p></div> -</dd> -<dt id="pluginconf.setup.name_to_fn"><code class="name flex"> -<span>def <span class="ident">name_to_fn</span></span>(<span>name)</span> -</code></dt> -<dd> -<div class="desc"><p>find primary entry point.py from package name</p></div> -</dd> <dt id="pluginconf.setup.setup"><code class="name flex"> <span>def <span class="ident">setup</span></span>(<span>filename=None, debug=False, **kwargs)</span> </code></dt> <dd> <div class="desc"><p>Wrapper around <code>setuptools.setup()</code> which adds some defaults @@ -99,10 +87,22 @@ <span>def <span class="ident">datafiles_man</span></span>(<span>)</span> </code></dt> <dd> <div class="desc"><p>data_files=</p></div> </dd> +<dt id="pluginconf.setup.MetaUtils.get_readme"><code class="name flex"> +<span>def <span class="ident">get_readme</span></span>(<span>prefix='long_')</span> +</code></dt> +<dd> +<div class="desc"><p>get README.md contents</p></div> +</dd> +<dt id="pluginconf.setup.MetaUtils.name_to_fn"><code class="name flex"> +<span>def <span class="ident">name_to_fn</span></span>(<span>name)</span> +</code></dt> +<dd> +<div class="desc"><p>find primary entry point.py from package name</p></div> +</dd> </dl> <h3>Methods</h3> <dl> <dt id="pluginconf.setup.MetaUtils.classifiers"><code class="name flex"> <span>def <span class="ident">classifiers</span></span>(<span>self)</span> @@ -133,11 +133,11 @@ </code></dt> <dd> <div class="desc"><p>depends: python:module, pip:module</p></div> </dd> <dt id="pluginconf.setup.MetaUtils.plugin_doc"><code class="name flex"> -<span>def <span class="ident">plugin_doc</span></span>(<span>self)</span> +<span>def <span class="ident">plugin_doc</span></span>(<span>self, prefix='long_')</span> </code></dt> <dd> <div class="desc"><p>use comment block</p></div> </dd> <dt id="pluginconf.setup.MetaUtils.project_urls"><code class="name flex"> @@ -180,12 +180,10 @@ <li><code><a title="pluginconf" href="index.html">pluginconf</a></code></li> </ul> </li> <li><h3><a href="#header-functions">Functions</a></h3> <ul class=""> -<li><code><a title="pluginconf.setup.get_readme" href="#pluginconf.setup.get_readme">get_readme</a></code></li> -<li><code><a title="pluginconf.setup.name_to_fn" href="#pluginconf.setup.name_to_fn">name_to_fn</a></code></li> <li><code><a title="pluginconf.setup.setup" href="#pluginconf.setup.setup">setup</a></code></li> </ul> </li> <li><h3><a href="#header-classes">Classes</a></h3> <ul> @@ -195,11 +193,13 @@ <li><code><a title="pluginconf.setup.MetaUtils.classifiers" href="#pluginconf.setup.MetaUtils.classifiers">classifiers</a></code></li> <li><code><a title="pluginconf.setup.MetaUtils.datafiles_man" href="#pluginconf.setup.MetaUtils.datafiles_man">datafiles_man</a></code></li> <li><code><a title="pluginconf.setup.MetaUtils.entry_points" href="#pluginconf.setup.MetaUtils.entry_points">entry_points</a></code></li> <li><code><a title="pluginconf.setup.MetaUtils.extras_require" href="#pluginconf.setup.MetaUtils.extras_require">extras_require</a></code></li> <li><code><a title="pluginconf.setup.MetaUtils.get_keywords" href="#pluginconf.setup.MetaUtils.get_keywords">get_keywords</a></code></li> +<li><code><a title="pluginconf.setup.MetaUtils.get_readme" href="#pluginconf.setup.MetaUtils.get_readme">get_readme</a></code></li> <li><code><a title="pluginconf.setup.MetaUtils.install_requires" href="#pluginconf.setup.MetaUtils.install_requires">install_requires</a></code></li> +<li><code><a title="pluginconf.setup.MetaUtils.name_to_fn" href="#pluginconf.setup.MetaUtils.name_to_fn">name_to_fn</a></code></li> <li><code><a title="pluginconf.setup.MetaUtils.plugin_doc" href="#pluginconf.setup.MetaUtils.plugin_doc">plugin_doc</a></code></li> <li><code><a title="pluginconf.setup.MetaUtils.project_urls" href="#pluginconf.setup.MetaUtils.project_urls">project_urls</a></code></li> <li><code><a title="pluginconf.setup.MetaUtils.python_requires" href="#pluginconf.setup.MetaUtils.python_requires">python_requires</a></code></li> <li><code><a title="pluginconf.setup.MetaUtils.trove_license" href="#pluginconf.setup.MetaUtils.trove_license">trove_license</a></code></li> <li><code><a title="pluginconf.setup.MetaUtils.trove_status" href="#pluginconf.setup.MetaUtils.trove_status">trove_status</a></code></li> Index: pluginconf/__init__.py ================================================================== --- pluginconf/__init__.py +++ pluginconf/__init__.py @@ -2,11 +2,11 @@ # api: python ##type: extract # category: config # title: Plugin configuration # description: Read meta data, pyz/package contents, module locating -# version: 0.8.0 +# version: 0.8.1 # state: stable # classifiers: documentation # depends: python >= 2.7 # suggests: python:flit, python:PySimpleGUI # license: PD Index: pluginconf/bind.py ================================================================== --- pluginconf/bind.py +++ pluginconf/bind.py @@ -169,11 +169,11 @@ Module should be a package, as in a directory and init `plugins/__init__.py`. Ideally this module was already imported in main. But parameter may be a string. This could be invoked multiple times for the package name to append further path= arguments (=./contrib/, =/usr/share/app/extenstions/, or a .pyz). Which - is functionally identical to delcaring `__path__` in the `package/__init__.py`. + is functionally identical to declaring `__path__` in the `package/__init__.py`. """ # if supplied as string, instead of active module if isinstance(module, str): module = sys.modules.get(module) or __import__(module) Index: pluginconf/flit.py ================================================================== --- pluginconf/flit.py +++ pluginconf/flit.py @@ -153,15 +153,13 @@ "provides_extra": [], } #print(meta) # comment/readme - for docs in pmd.plugin_doc(), psetup.get_readme(): - if docs["long_description"]: - meta.update({ # with "long_" prefix cut off - key[5:]: value for key, value in docs.items() - }) + for docs in pmd.plugin_doc(prefix=""), pmd.get_readme(prefix=""): + if docs["description"]: + meta.update(docs) # entry_points are in ini file for section, entries in pmd.entry_points().items(): ini.entrypoints[section] = ini.entrypoints.get(section, {}) for script in entries: Index: pluginconf/setup.py ================================================================== --- pluginconf/setup.py +++ pluginconf/setup.py @@ -52,45 +52,47 @@ import glob import pprint import pluginconf -def name_to_fn(name): - """ find primary entry point.py from package name """ - for pfx in "", "src/", "src/"+name+"/": - for sfx in ".py", "/__init__.py": - if os.path.exists(pfx+name+sfx): - return pfx+name+sfx - return "" - -def get_readme(): - """ get README.md contents """ - for filename, mime in ("README.md", "text/markdown"), ("README.rst", "text/x-rst"), ("README.txt", "text/plain"): - if os.path.exists(filename): - with open(filename, "r") as read: - return { - "long_description": read.read(), - "long_description_content_type": mime, - } - return { - "long_description": "", - "long_description_content_type": "text/plain", - } - class MetaUtils(dict): """ Convenience access to PMD fields and conversion functions """ def __getattr__(self, name): """ dict into properties """ return self.get(name, "") - def plugin_doc(self): + @staticmethod + def name_to_fn(name): + """ find primary entry point.py from package name """ + for pfx in "", "src/", "src/"+name+"/": + for sfx in ".py", "/__init__.py": + if os.path.exists(pfx+name+sfx): + return pfx+name+sfx + return "" + + @staticmethod + def get_readme(prefix="long_"): + """ get README.md contents """ + for filename, mime in ("README.md", "text/markdown"), ("README.rst", "text/x-rst"), ("README.txt", "text/plain"): + if os.path.exists(filename): + with open(filename, "r") as read: + return { + prefix+"description": read.read(), + prefix+"description_content_type": mime, + } + return { + prefix+"description": "", + prefix+"description_content_type": "text/plain", + } + + def plugin_doc(self, prefix="long_"): """ use comment block """ return { - "long_description": self.doc, - "long_description_content_type": self.doc_format or "text/plain" + prefix+"description": self.doc, + prefix+"description_content_type": self.doc_format or "text/plain" } def python_requires(self): """ depends: python >= 3.5 """ deps = re.findall(r"python\s*\(?(>=?\s?[\d.]+)", self.get("depends", "")) @@ -236,17 +238,14 @@ # package name if "name" not in kwargs and kwargs.get("packages"): kwargs["name"] = kwargs["packages"][0] - # read README if field empty or says `@README` - if re.match("^$|^[@./]*README.{0,5}$", kwargs.get("long_description", "")): - kwargs.update(get_readme()) # search name= package if no filename= given if not filename and kwargs.get("name"): - filename = name_to_fn(kwargs["name"]) + filename = MetaUtils.name_to_fn(kwargs["name"]) # read plugin meta data (PMD) pmd = MetaUtils( pluginconf.plugin_meta(filename=filename) ) @@ -270,10 +269,13 @@ if "depends" in pmd and not kwargs["install_requires"]: kwargs["install_requires"] = pmd.install_requires() # suggests: if "suggests" in pmd and not kwargs["extras_require"]: kwargs["extras_require"].update(pmd.extras_require()) + # read README if field empty or says `@README` + if re.match("^$|^[@./]*README.{0,5}$", kwargs.get("long_description", "")): + kwargs.update(pmd.get_readme()) # doc: if not kwargs.get("long_description"): kwargs.update(pmd.plugin_doc()) # keywords=