-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update README, setup.py, and README generate files
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
1 parent
980b1f9
commit 2f8a578
Showing
6 changed files
with
129 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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', | ||
] | ||
} | ||
|
||
) | ||
) | ||
|