Commit 7c91d2e8 authored by Sasha Z's avatar Sasha Z
Browse files

Reorg for packaging

parent ea90038e
# SNS RAD
Currently only reading of binary files is implemented.
\ No newline at end of file
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 27 16:11:06 2020
@author: az9
"""
from sns_rad.binary import ReadStorage
import argparse
from argparse import RawTextHelpFormatter
epilog_text = '''
Examples:
python read_file.py filename
# will read and print out all records from <filename>
python read_file.py -i n1 -i n2 filename
# will read and print out records with indices n1 and n2 from <filename>
'''
parser = argparse.ArgumentParser(epilog=epilog_text, formatter_class=RawTextHelpFormatter)
parser.add_argument('--index', '-i', action='append', default=[], type=int,
help='indices of records to read')
parser.add_argument('file', help='file to read')
args = parser.parse_args()
file = ReadStorage(args.file)
print(args.file, 'has', len(file), 'records')
def show(record):
if 'value' in record:
value = record['value']
# if isinstance(value,(str,list,tuple)):
if hasattr(value, '__len__') and len(value) > 4:
record['value'] = [value[0], value[1], '...', value[len(value) - 1]]
return record
def show2(record):
return str(record['name']) + ' ' + str(record['timestamp'])
if not args.index:
for record in file:
print(show2(record))
else:
for i in args.index:
print(i, ":", show2(file[i]))
file.close()
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="sns_rad",
version="0.0.1",
author="Alexander Zhukov",
author_email="zhukovap@ornl.gov",
description="Package for code developed at SNS RAD.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://",
# scripts=['read_binary'],
entry_points={
"console_scripts": [
"read_binary = sns_rad.read_binary:main",
]},
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3.6',
)
\ No newline at end of file
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 27 16:11:06 2020
@author: az9
"""
from sns_rad.binary import ReadStorage
import argparse
from argparse import RawTextHelpFormatter
def main():
epilog_text = '''
Examples:
python read_file.py filename
# will read and print out all records from <filename>
python read_file.py -i n1 -i n2 filename
# will read and print out records with indices n1 and n2 from <filename>
'''
parser = argparse.ArgumentParser(epilog=epilog_text, formatter_class=RawTextHelpFormatter)
parser.add_argument('--index', '-i', action='append', default=[], type=int,
help='indices of records to read')
parser.add_argument('file', help='file to read')
args = parser.parse_args()
file = ReadStorage(args.file)
print(args.file, 'has', len(file), 'records')
def show(record):
if 'value' in record:
value = record['value']
# if isinstance(value,(str,list,tuple)):
if hasattr(value, '__len__') and len(value) > 4:
record['value'] = [value[0], value[1], '...', value[len(value) - 1]]
return record
def show2(record):
return str(record['name']) + ' ' + str(record['timestamp'])
if not args.index:
for record in file:
print(show2(record))
else:
for i in args.index:
print(i, ":", show2(file[i]))
file.close()
if __name__ == "__main__":
main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment