Skip to content

Commit

Permalink
Update README, setup.py, and README generate files
Browse files Browse the repository at this point in the history
Move readme script and template to a subfolder to decrease top-level
clutter. README files generated by generate-readme.py are now created
with read-only permissions, to avoid accidental updates to the wrong
file.
  • Loading branch information
lucas-flowers committed Sep 20, 2017
1 parent 980b1f9 commit 2f8a578
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 120 deletions.
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ Command Line Summary
GUI
---

The ``snutree`` package also includes a simple GUI called ``snutree-qt``. The
GUI can take multiple input files of any supported format, pick schemas, output
to PDF, and choose a seed for the random number generator.
There is also a simple GUI script called ``snutree-gui``. It is a simple
wrapper over the command-line version and implements most of the command-line
features.

Installation
============
Expand Down Expand Up @@ -199,7 +199,7 @@ Optional Dependencies

Use ``pip`` to install these packages for optional features:

- ``pyqt5``: Use the GUI
- ``gooey``: Use the GUI version

- ``mysqlclient``: Allow reading from MySQL databases

Expand Down
74 changes: 74 additions & 0 deletions docs/readme-generate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env python

import os
import sys
from stat import S_IREAD, S_IRGRP, S_IROTH
import subprocess
from pathlib import Path
from textwrap import indent
from snutree import api
import snutree.readers.csv as reader_csv
import snutree.readers.sql as reader_sql
import snutree.readers.dot as reader_dot
import snutree.schemas.sigmanu as schema_sigmanu
import snutree.writers.dot as writer_dot
from snutree.utilities.cerberus import describe_schema

SNUTREE_ROOT = Path(__file__).parent.parent.resolve()

def get_template():
with open(str(SNUTREE_ROOT/'docs/readme-template.rst'), 'r') as f:
return f.read()

def generate_readme(template):

# Get usage information
result = subprocess.run(
[str(SNUTREE_ROOT/'snutree.py'), '--help'],
stdout=subprocess.PIPE,
universal_newlines=True, # Python 3.5
# encoding=sys.getdefaultencoding(), # Python 3.6
)
return_code = result.returncode
if return_code:
sys.exit(return_code)
usage = result.stdout

return template.format(
CLI_HELP=indent(usage, ' '*4),
CONFIG_API=describe_schema(api.CONFIG_SCHEMA, level=2),
CONFIG_READER_CSV=describe_schema(reader_csv.CONFIG_SCHEMA, level=2),
CONFIG_READER_SQL=describe_schema(reader_sql.CONFIG_SCHEMA, level=2),
CONFIG_READER_DOT=describe_schema(reader_dot.CONFIG_SCHEMA, level=2),
CONFIG_SCHEMA_SIGMANU=describe_schema(schema_sigmanu.CONFIG_SCHEMA, level=2),
CONFIG_WRITER_DOT=describe_schema(writer_dot.CONFIG_SCHEMA, level=2),
)

def write_readme(readme):
path = SNUTREE_ROOT/'README.rst'
if path.exists():
path.unlink()
with open(str(path), 'w+') as f:
f.write(readme)
# Discourage writing to the generated file
os.fchmod(f.fileno(), S_IREAD | S_IRGRP | S_IROTH)

def check_readme():
return subprocess.run([
'python',
'setup.py',
'check',
'--restructuredtext',
'--strict',
], stdout=subprocess.DEVNULL).returncode

def main():
template = get_template()
readme = generate_readme(template)
write_readme(readme)
return_code = check_readme()
sys.exit(return_code)

if __name__ == '__main__':
main()

8 changes: 4 additions & 4 deletions README_TEMPLATE.rst → docs/readme-template.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ Command Line Summary
GUI
---

The ``snutree`` package also includes a simple GUI called ``snutree-qt``. The
GUI can take multiple input files of any supported format, pick schemas, output
to PDF, and choose a seed for the random number generator.
There is also a simple GUI script called ``snutree-gui``. It is a simple
wrapper over the command-line version and implements most of the command-line
features.

Installation
============
Expand Down Expand Up @@ -152,7 +152,7 @@ Optional Dependencies

Use ``pip`` to install these packages for optional features:

- ``pyqt5``: Use the GUI
- ``gooey``: Use the GUI version

- ``mysqlclient``: Allow reading from MySQL databases

Expand Down
65 changes: 0 additions & 65 deletions generate-readme.py

This file was deleted.

2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ upload:
twine upload -r pypi dist/*

readme:
python generate-readme.py
python docs/readme-generate.py

test-clean: py-clean
find . -name '*-actual.dot' -exec rm {} +
Expand Down
92 changes: 46 additions & 46 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,58 +8,58 @@

setup(

name='snutree',
use_scm_version=True,
setup_requires=['setuptools_scm'],
description='Visualize big–little brother/sister relationships in Greek-letter organizations',
long_description=long_description,
url='https://github.com/lucas-flowers/snutree',
author='Lucas Flowers',
author_email='[email protected]',
license='GPLv3',
name='snutree',
use_scm_version=True,
setup_requires=['setuptools_scm'],
description='Visualize big–little brother/sister relationships in Greek-letter organizations',
long_description=long_description,
url='https://github.com/lucas-flowers/snutree',
author='Lucas Flowers',
author_email='[email protected]',
license='GPLv3',

classifiers = [
'Development Status :: 4 - Beta',
'Intended Audience :: Other Audience',
'Topic :: Other/Nonlisted Topic',
'Topic :: Utilities',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python :: 3.5',
],
classifiers = [
'Development Status :: 4 - Beta',
'Intended Audience :: Other Audience',
'Topic :: Other/Nonlisted Topic',
'Topic :: Utilities',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python :: 3.5',
],

keywords='big little brother sister family tree',
packages=find_packages(exclude=['tests']),
keywords='big little brother sister family tree',
packages=find_packages(exclude=['tests']),

install_requires=[
'Cerberus',
'networkx',
'pluginbase',
'PyYAML',
'voluptuous',
],
install_requires=[
'Cerberus',
'networkx',
'pluginbase',
'PyYAML',
'voluptuous',
],

python_requires='>=3.5',
python_requires='>=3.5',

extras_require={
'develop' : ['pytest', 'docutils', 'faker'],
'test' : ['pytest'],
'gui' : ['gooey', 'psutil'], # psutil appears to be an unlisted dependency of gooey
'read_sql' : ['mysqlclient'],
'read_sql_ssh' : ['mysqlclient', 'sshtunnel'],
'read_dot' : ['pydotplus']
},
extras_require={
'develop' : ['pytest', 'docutils', 'faker'],
'test' : ['pytest'],
'gui' : ['gooey', 'psutil'], # psutil appears to be an unlisted dependency of gooey
'sql' : ['mysqlclient'],
'ssh' : ['sshtunnel'],
'dot' : ['pydotplus']
},

package_data={
'' : ['*.txt'],
'snutree' : ['readers/*.py', 'schemas/*.py', 'writers/*.py'],
},
package_data={
'' : ['*.txt'],
'snutree' : ['readers/*.py', 'schemas/*.py', 'writers/*.py'],
},

entry_points={
'console_scripts' : [
'snutree=snutree.cli:main',
'snutree-gui=snutree.gui:main',
]
}
entry_points={
'console_scripts' : [
'snutree=snutree.cli:main',
'snutree-gui=snutree.gui:main',
]
}

)
)

0 comments on commit 2f8a578

Please sign in to comment.