/usr/lib/python2.7/dist-packages/pint/__init__.py is in python-pint 0.6-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | # -*- coding: utf-8 -*-
"""
pint
~~~~
Pint is Python module/package to define, operate and manipulate
**physical quantities**: the product of a numerical value and a
unit of measurement. It allows arithmetic operations between them
and conversions from and to different units.
:copyright: (c) 2012 by Hernan E. Grecco.
:license: BSD, see LICENSE for more details.
"""
from __future__ import with_statement
import os
import subprocess
import pkg_resources
from .formatting import formatter
from .unit import (UnitRegistry, DimensionalityError, OffsetUnitCalculusError,
UndefinedUnitError, LazyRegistry)
from .util import pi_theorem, logger
from .context import Context
try: # pragma: no cover
__version__ = pkg_resources.get_distribution('pint').version
except: # pragma: no cover
# we seem to have a local copy not installed without setuptools
# so the reported version will be unknown
__version__ = "unknown"
#: A Registry with the default units and constants.
_DEFAULT_REGISTRY = LazyRegistry()
#: Registry used for unpickling operations.
_APP_REGISTRY = _DEFAULT_REGISTRY
def _build_quantity(value, units):
"""Build Quantity using the Application registry.
Used only for unpickling operations.
"""
global _APP_REGISTRY
return _APP_REGISTRY.Quantity(value, units)
def set_application_registry(registry):
"""Set the application registry which is used for unpickling operations.
:param registry: a UnitRegistry instance.
"""
assert isinstance(registry, UnitRegistry)
global _APP_REGISTRY
logger.debug('Changing app registry from %r to %r.', _APP_REGISTRY, registry)
_APP_REGISTRY = registry
def _run_pyroma(data): # pragma: no cover
"""Run pyroma (used to perform checks before releasing a new version).
"""
import sys
from zest.releaser.utils import ask
if not ask("Run pyroma on the package before uploading?"):
return
try:
from pyroma import run
result = run(data['tagdir'])
if result != 10:
if not ask("Continue?"):
sys.exit(1)
except ImportError:
if not ask("pyroma not available. Continue?"):
sys.exit(1)
def _check_travis(data): # pragma: no cover
"""Check if Travis reports that everything is ok.
(used to perform checks before releasing a new version).
"""
import json
import sys
from zest.releaser.utils import system, ask
if not ask('Check with Travis before releasing?'):
return
try:
# Python 3
from urllib.request import urlopen
def get(url):
return urlopen(url).read().decode('utf-8')
except ImportError:
# Python 2
from urllib2 import urlopen
def get(url):
return urlopen(url).read()
url = 'https://api.github.com/repos/%s/%s/status/%s'
username = 'hgrecco'
repo = 'pint'
commit = system('git rev-parse HEAD')
try:
result = json.loads(get(url % (username, repo, commit)))['state']
print('Travis says: %s' % result)
if result != 'success':
if not ask('Do you want to continue anyway?', default=False):
sys.exit(1)
except Exception:
print('Could not determine the commit state with Travis.')
if ask('Do you want to continue anyway?', default=False):
sys.exit(1)
def test():
"""Run all tests.
:return: a :class:`unittest.TestResult` object
"""
from .testsuite import run
return run()
|