doct
Advanced tools
+27
| Copyright (c) 2015, Brookhaven Science Associates, Brookhaven National | ||
| Laboratory. All rights reserved. | ||
| Redistribution and use in source and binary forms, with or without | ||
| modification, are permitted provided that the following conditions are met: | ||
| * Redistributions of source code must retain the above copyright notice, this | ||
| list of conditions and the following disclaimer. | ||
| * Redistributions in binary form must reproduce the above copyright notice, | ||
| this list of conditions and the following disclaimer in the documentation | ||
| and/or other materials provided with the distribution. | ||
| * Neither the name of the Brookhaven Science Associates, Brookhaven National | ||
| Laboratory nor the names of its contributors may be used to endorse or promote | ||
| products derived from this software without specific prior written permission. | ||
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
| FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
| OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| # Document | ||
| `Document` is a light-weight sub-class of the built in `dict` which is | ||
| 1. read only | ||
| 2. has `.` (`getattr`) access | ||
| 3. knows it's `_name` |
@@ -1,10 +0,9 @@ | ||
| Metadata-Version: 1.0 | ||
| Metadata-Version: 2.1 | ||
| Name: doct | ||
| Version: 1.0.5 | ||
| Version: 1.1.0 | ||
| Summary: A read-only dottable dictionary | ||
| Home-page: http://github.com/NSLS-II/doct | ||
| Author: Brookhaven National Laboratory | ||
| Author-email: UNKNOWN | ||
| License: BSD 3-Clause | ||
| Description: UNKNOWN | ||
| Platform: UNKNOWN | ||
| Requires-Python: >=3.6 | ||
| License-File: LICENSE |
@@ -1,3 +0,2 @@ | ||
| six | ||
| humanize | ||
| prettytable |
@@ -0,1 +1,3 @@ | ||
| LICENSE | ||
| README.md | ||
| doct.py | ||
@@ -2,0 +4,0 @@ setup.py |
+16
-13
@@ -30,5 +30,3 @@ """ | ||
| """ | ||
| from __future__ import absolute_import, division, print_function | ||
| import six | ||
| import collections | ||
| from collections.abc import Mapping | ||
| from functools import reduce | ||
@@ -101,15 +99,15 @@ import time | ||
| return (k for k in super(Document, self).__iter__() | ||
| if not (isinstance(k, six.string_types) and k.startswith('_'))) | ||
| if not (isinstance(k, str) and k.startswith('_'))) | ||
| def items(self): | ||
| return ((k, v) for k, v in super(Document, self).items() | ||
| if not (isinstance(k, six.string_types) and k.startswith('_'))) | ||
| if not (isinstance(k, str) and k.startswith('_'))) | ||
| def values(self): | ||
| return (v for k, v in super(Document, self).items() | ||
| if not (isinstance(k, six.string_types) and k.startswith('_'))) | ||
| if not (isinstance(k, str) and k.startswith('_'))) | ||
| def keys(self): | ||
| return (k for k in super(Document, self).keys() | ||
| if not (isinstance(k, six.string_types) and k.startswith('_'))) | ||
| if not (isinstance(k, str) and k.startswith('_'))) | ||
@@ -157,3 +155,4 @@ def __len__(self): | ||
| ret = dict(self) | ||
| name = ret.pop('_name') | ||
| ret.pop('_name', None) | ||
| name = self._name | ||
| return name, ret | ||
@@ -164,3 +163,7 @@ | ||
| # timestamp needs to be a float or fromtimestamp() will barf | ||
| timestamp = float(timestamp) | ||
| try: | ||
| timestamp = float(timestamp) | ||
| except (TypeError, ValueError): | ||
| # not a float, assume it is already as pretty as it will get | ||
| return timestamp | ||
| dt = datetime.datetime.fromtimestamp(timestamp).isoformat() | ||
@@ -173,4 +176,4 @@ ago = humanize.naturaltime(time.time() - timestamp) | ||
| ret = '' | ||
| for k, v in six.iteritems(value): | ||
| if isinstance(v, collections.Mapping): | ||
| for k, v in value.items(): | ||
| if isinstance(v, Mapping): | ||
| ret += _format_dict(v, name_width, value_width, k, tabs=tabs+1) | ||
@@ -186,3 +189,3 @@ else: | ||
| fields = reduce(set.union, | ||
| (set(v) for v in six.itervalues(data_keys_dict))) | ||
| (set(v) for v in data_keys_dict.values())) | ||
| fields = sorted(list(fields)) | ||
@@ -232,3 +235,3 @@ table = PrettyTable(["data keys"] + list(fields)) | ||
| ret += "\n%s" % str(_format_data_keys_dict(value)) | ||
| elif isinstance(value, collections.Mapping): | ||
| elif isinstance(value, Mapping): | ||
| if '_name' in value: | ||
@@ -235,0 +238,0 @@ documents.append((name, value)) |
+4
-5
@@ -1,10 +0,9 @@ | ||
| Metadata-Version: 1.0 | ||
| Metadata-Version: 2.1 | ||
| Name: doct | ||
| Version: 1.0.5 | ||
| Version: 1.1.0 | ||
| Summary: A read-only dottable dictionary | ||
| Home-page: http://github.com/NSLS-II/doct | ||
| Author: Brookhaven National Laboratory | ||
| Author-email: UNKNOWN | ||
| License: BSD 3-Clause | ||
| Description: UNKNOWN | ||
| Platform: UNKNOWN | ||
| Requires-Python: >=3.6 | ||
| License-File: LICENSE |
+3
-2
@@ -5,3 +5,3 @@ from setuptools import setup | ||
| name='doct', | ||
| version='1.0.5', | ||
| version='1.1.0', | ||
| author='Brookhaven National Laboratory', | ||
@@ -12,3 +12,4 @@ license='BSD 3-Clause', | ||
| url='http://github.com/NSLS-II/doct', | ||
| install_requires=['six', 'humanize', 'prettytable'] | ||
| install_requires=['humanize', 'prettytable'], | ||
| python_requires='>=3.6' | ||
| ) |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
11331
18.35%11
22.22%228
1.79%