[Python-modules-commits] [wolframalpha] 01/04: import wolframalpha_1.4.orig.tar.gz

Ethan Ward ethanward-guest at moszumanska.debian.org
Wed Jul 26 17:33:26 UTC 2017


This is an automated email from the git hooks/post-receive script.

ethanward-guest pushed a commit to branch master
in repository wolframalpha.

commit 641c70c54c72631f5915c55f887b3ad9cb07cb04
Author: Ethan Ward <ethan.ward at mycroft.ai>
Date:   Wed Jul 26 12:23:44 2017 -0500

    import wolframalpha_1.4.orig.tar.gz
---
 .eggs/README.txt                           |   6 +++
 .eggs/setuptools_scm-1.15.5-py2.7.egg      | Bin 0 -> 26963 bytes
 .hgignore                                  |   2 +
 .hgtags                                    |   7 +++
 .travis.yml                                |  10 ++++
 CHANGES.txt                                |   9 ++++
 PKG-INFO                                   |  61 ++++++++++++++++++++++
 README.txt                                 |  46 +++++++++++++++++
 docs/conf.py                               |  19 +++++++
 docs/history.rst                           |   8 +++
 docs/index.rst                             |  22 ++++++++
 pytest.ini                                 |   4 ++
 setup.cfg                                  |  12 +++++
 setup.py                                   |  56 ++++++++++++++++++++
 wolframalpha.egg-info/PKG-INFO             |  61 ++++++++++++++++++++++
 wolframalpha.egg-info/SOURCES.txt          |  21 ++++++++
 wolframalpha.egg-info/dependency_links.txt |   1 +
 wolframalpha.egg-info/entry_points.txt     |   3 ++
 wolframalpha.egg-info/requires.txt         |   1 +
 wolframalpha.egg-info/top_level.txt        |   1 +
 wolframalpha/__init__.py                   |  79 +++++++++++++++++++++++++++++
 wolframalpha/compat.py                     |  14 +++++
 wolframalpha/pmxbot.py                     |  10 ++++
 wolframalpha/test_client.py                |  22 ++++++++
 24 files changed, 475 insertions(+)

diff --git a/.eggs/README.txt b/.eggs/README.txt
new file mode 100644
index 0000000..5d01668
--- /dev/null
+++ b/.eggs/README.txt
@@ -0,0 +1,6 @@
+This directory contains eggs that were downloaded by setuptools to build, test, and run plug-ins.
+
+This directory caches those eggs to prevent repeated downloads.
+
+However, it is safe to delete this directory.
+
diff --git a/.eggs/setuptools_scm-1.15.5-py2.7.egg b/.eggs/setuptools_scm-1.15.5-py2.7.egg
new file mode 100644
index 0000000..13037b4
Binary files /dev/null and b/.eggs/setuptools_scm-1.15.5-py2.7.egg differ
diff --git a/.hgignore b/.hgignore
new file mode 100644
index 0000000..9d0b71a
--- /dev/null
+++ b/.hgignore
@@ -0,0 +1,2 @@
+build
+dist
diff --git a/.hgtags b/.hgtags
new file mode 100644
index 0000000..425e54c
--- /dev/null
+++ b/.hgtags
@@ -0,0 +1,7 @@
+84c2ea659f392fd0869d1390528ded791b35eda8 1.0
+f5ff7fd7358b54d5c9a443266b9ac9a3a20ffa60 1.0.1
+c692ddc5b59bd014894c86ab662e221023b0b84c 1.0.2
+b3ef10a751ad968010fff3277feb1bad698838fd 1.1
+f2081524a7df007877ea0e8f692ededb982dc1e7 1.2
+00a63ffafb3961ba1368c5bbfd6064b59c788127 1.3
+eeef6cfb992fd569ee0b0cae9d30e65d761a6dc7 1.4
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..26a7508
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,10 @@
+sudo: false
+language: python
+python:
+  - 2.7
+  - 3.4
+  - 3.5
+  - pypy
+script:
+ - pip install -U pytest
+ - python setup.py test
diff --git a/CHANGES.txt b/CHANGES.txt
new file mode 100644
index 0000000..7553131
--- /dev/null
+++ b/CHANGES.txt
@@ -0,0 +1,9 @@
+1.4
+===
+
+Add pmxbot module and plugin, superseding pmxbot-wolframalpha package.
+
+1.3
+===
+
+Moved hosting to Github.
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..e74a9ac
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,61 @@
+Metadata-Version: 1.1
+Name: wolframalpha
+Version: 1.4
+Summary: Wolfram|Alpha 2.0 API client
+Home-page: https://github.com/jaraco/wolframalpha
+Author: Jason R. Coombs
+Author-email: jaraco at jaraco.com
+License: UNKNOWN
+Description: wolframalpha
+        ============
+        
+        Python Client built against the `Wolfram|Alpha <http://wolframalpha.com>`_
+        v2.0 API. This project is hosted on `bitbucket
+        <https://github.com/jaraco/wolframalpha>`_.
+        
+        Installation
+        ============
+        
+        This library is released to PyPI, so the easiest way to install it is to use
+        easy_install::
+        
+            easy_install wolframalpha
+        
+        or pip::
+        
+            pip install wolframalpha
+        
+        If you don't have these tools or you prefer not to use setuptools, you may
+        also simply extract the 'wolframalpha' directory an appropriate location in
+        your Python path.
+        
+        Usage
+        =====
+        
+        Basic usage is pretty simple. Create the client with your App ID (request from
+        Wolfram Alpha)::
+        
+            import wolframalpha
+            client = wolframalpha.Client(app_id)
+        
+        Then, you can send queries, which return Result objects::
+        
+            res = client.query('temperature in Washington, DC on October 3, 2012')
+        
+        Result objects have `pods` attribute (a Pod is an answer from Wolfram Alpha)::
+        
+            for pod in res.pods:
+                do_something_with(pod)
+        
+        You may also query for simply the pods which have 'Result' titles::
+        
+            print(next(res.results).text)
+        
+        For more information, read the source.
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..79f17c8
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,46 @@
+wolframalpha
+============
+
+Python Client built against the `Wolfram|Alpha <http://wolframalpha.com>`_
+v2.0 API. This project is hosted on `bitbucket
+<https://github.com/jaraco/wolframalpha>`_.
+
+Installation
+============
+
+This library is released to PyPI, so the easiest way to install it is to use
+easy_install::
+
+    easy_install wolframalpha
+
+or pip::
+
+    pip install wolframalpha
+
+If you don't have these tools or you prefer not to use setuptools, you may
+also simply extract the 'wolframalpha' directory an appropriate location in
+your Python path.
+
+Usage
+=====
+
+Basic usage is pretty simple. Create the client with your App ID (request from
+Wolfram Alpha)::
+
+    import wolframalpha
+    client = wolframalpha.Client(app_id)
+
+Then, you can send queries, which return Result objects::
+
+    res = client.query('temperature in Washington, DC on October 3, 2012')
+
+Result objects have `pods` attribute (a Pod is an answer from Wolfram Alpha)::
+
+    for pod in res.pods:
+        do_something_with(pod)
+
+You may also query for simply the pods which have 'Result' titles::
+
+    print(next(res.results).text)
+
+For more information, read the source.
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644
index 0000000..ebc552c
--- /dev/null
+++ b/docs/conf.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import setuptools_scm
+
+extensions = [
+    'sphinx.ext.autodoc',
+]
+
+# General information about the project.
+project = 'wolframalpha'
+copyright = '2015 Jason R. Coombs'
+
+# The short X.Y version.
+version = setuptools_scm.get_version(root='..', relative_to=__file__)
+# The full version, including alpha/beta/rc tags.
+release = version
+
+master_doc = 'index'
diff --git a/docs/history.rst b/docs/history.rst
new file mode 100644
index 0000000..e3cd55d
--- /dev/null
+++ b/docs/history.rst
@@ -0,0 +1,8 @@
+:tocdepth: 2
+
+.. _changes:
+
+History
+*******
+
+.. include:: ../CHANGES.txt
diff --git a/docs/index.rst b/docs/index.rst
new file mode 100644
index 0000000..92979c6
--- /dev/null
+++ b/docs/index.rst
@@ -0,0 +1,22 @@
+Welcome to wolframalpha documentation!
+========================================
+
+.. toctree::
+   :maxdepth: 1
+
+   history
+
+
+.. automodule:: wolframalpha
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
diff --git a/pytest.ini b/pytest.ini
new file mode 100644
index 0000000..9752c36
--- /dev/null
+++ b/pytest.ini
@@ -0,0 +1,4 @@
+[pytest]
+norecursedirs=*.egg .eggs dist build
+addopts=--doctest-modules
+doctest_optionflags=ALLOW_UNICODE ELLIPSIS
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..a880e96
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,12 @@
+[aliases]
+release = sdist bdist_wheel build_sphinx upload upload_docs
+test = pytest
+
+[wheel]
+universal = 1
+
+[egg_info]
+tag_svn_revision = 0
+tag_build = 
+tag_date = 0
+
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..5b06513
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+# Generated by jaraco.develop 2.23
+# https://pypi.python.org/pypi/jaraco.develop
+
+import io
+import sys
+
+import setuptools
+
+with io.open('README.txt', encoding='utf-8') as readme:
+	long_description = readme.read()
+
+needs_pytest = {'pytest', 'test'}.intersection(sys.argv)
+pytest_runner = ['pytest_runner'] if needs_pytest else []
+needs_sphinx = {'release', 'build_sphinx', 'upload_docs'}.intersection(sys.argv)
+sphinx = ['sphinx'] if needs_sphinx else []
+needs_wheel = {'release', 'bdist_wheel'}.intersection(sys.argv)
+wheel = ['wheel'] if needs_wheel else []
+
+setup_params = dict(
+	name='wolframalpha',
+	use_scm_version=True,
+	author="Jason R. Coombs",
+	author_email="jaraco at jaraco.com",
+	description="Wolfram|Alpha 2.0 API client",
+	long_description=long_description,
+	url="https://github.com/jaraco/wolframalpha",
+	packages=setuptools.find_packages(),
+	include_package_data=True,
+	install_requires=[
+		'six',
+	],
+	extras_require={
+	},
+	setup_requires=[
+		'setuptools_scm>=1.9',
+	] + pytest_runner + sphinx + wheel,
+	tests_require=[
+		'pytest>=2.8',
+		'pmxbot',
+	],
+	classifiers=[
+		"Development Status :: 5 - Production/Stable",
+		"Intended Audience :: Developers",
+		"License :: OSI Approved :: MIT License",
+		"Programming Language :: Python :: 2.7",
+		"Programming Language :: Python :: 3",
+	],
+	entry_points={
+		'pmxbot_handlers': [
+		    'Wolfram|Alpha = wolframalpha.pmxbot',
+        	],
+	},
+)
+if __name__ == '__main__':
+	setuptools.setup(**setup_params)
diff --git a/wolframalpha.egg-info/PKG-INFO b/wolframalpha.egg-info/PKG-INFO
new file mode 100644
index 0000000..e74a9ac
--- /dev/null
+++ b/wolframalpha.egg-info/PKG-INFO
@@ -0,0 +1,61 @@
+Metadata-Version: 1.1
+Name: wolframalpha
+Version: 1.4
+Summary: Wolfram|Alpha 2.0 API client
+Home-page: https://github.com/jaraco/wolframalpha
+Author: Jason R. Coombs
+Author-email: jaraco at jaraco.com
+License: UNKNOWN
+Description: wolframalpha
+        ============
+        
+        Python Client built against the `Wolfram|Alpha <http://wolframalpha.com>`_
+        v2.0 API. This project is hosted on `bitbucket
+        <https://github.com/jaraco/wolframalpha>`_.
+        
+        Installation
+        ============
+        
+        This library is released to PyPI, so the easiest way to install it is to use
+        easy_install::
+        
+            easy_install wolframalpha
+        
+        or pip::
+        
+            pip install wolframalpha
+        
+        If you don't have these tools or you prefer not to use setuptools, you may
+        also simply extract the 'wolframalpha' directory an appropriate location in
+        your Python path.
+        
+        Usage
+        =====
+        
+        Basic usage is pretty simple. Create the client with your App ID (request from
+        Wolfram Alpha)::
+        
+            import wolframalpha
+            client = wolframalpha.Client(app_id)
+        
+        Then, you can send queries, which return Result objects::
+        
+            res = client.query('temperature in Washington, DC on October 3, 2012')
+        
+        Result objects have `pods` attribute (a Pod is an answer from Wolfram Alpha)::
+        
+            for pod in res.pods:
+                do_something_with(pod)
+        
+        You may also query for simply the pods which have 'Result' titles::
+        
+            print(next(res.results).text)
+        
+        For more information, read the source.
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
diff --git a/wolframalpha.egg-info/SOURCES.txt b/wolframalpha.egg-info/SOURCES.txt
new file mode 100644
index 0000000..ee1d4fb
--- /dev/null
+++ b/wolframalpha.egg-info/SOURCES.txt
@@ -0,0 +1,21 @@
+.hgignore
+.hgtags
+.travis.yml
+CHANGES.txt
+README.txt
+pytest.ini
+setup.cfg
+setup.py
+docs/conf.py
+docs/history.rst
+docs/index.rst
+wolframalpha/__init__.py
+wolframalpha/compat.py
+wolframalpha/pmxbot.py
+wolframalpha/test_client.py
+wolframalpha.egg-info/PKG-INFO
+wolframalpha.egg-info/SOURCES.txt
+wolframalpha.egg-info/dependency_links.txt
+wolframalpha.egg-info/entry_points.txt
+wolframalpha.egg-info/requires.txt
+wolframalpha.egg-info/top_level.txt
\ No newline at end of file
diff --git a/wolframalpha.egg-info/dependency_links.txt b/wolframalpha.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/wolframalpha.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/wolframalpha.egg-info/entry_points.txt b/wolframalpha.egg-info/entry_points.txt
new file mode 100644
index 0000000..3141037
--- /dev/null
+++ b/wolframalpha.egg-info/entry_points.txt
@@ -0,0 +1,3 @@
+[pmxbot_handlers]
+Wolfram|Alpha = wolframalpha.pmxbot
+
diff --git a/wolframalpha.egg-info/requires.txt b/wolframalpha.egg-info/requires.txt
new file mode 100644
index 0000000..ffe2fce
--- /dev/null
+++ b/wolframalpha.egg-info/requires.txt
@@ -0,0 +1 @@
+six
diff --git a/wolframalpha.egg-info/top_level.txt b/wolframalpha.egg-info/top_level.txt
new file mode 100644
index 0000000..222ee05
--- /dev/null
+++ b/wolframalpha.egg-info/top_level.txt
@@ -0,0 +1 @@
+wolframalpha
diff --git a/wolframalpha/__init__.py b/wolframalpha/__init__.py
new file mode 100644
index 0000000..afcda38
--- /dev/null
+++ b/wolframalpha/__init__.py
@@ -0,0 +1,79 @@
+from xml.etree import ElementTree as etree
+from six.moves import urllib
+
+from . import compat
+
+compat.fix_HTTPMessage()
+
+class Result(object):
+    def __init__(self, stream):
+        self.tree = etree.parse(stream)
+        self._handle_error()
+
+    def _handle_error(self):
+        error = self.tree.find('error')
+        if not error:
+            return
+
+        code = error.find('code').text
+        msg = error.find('msg').text
+        tmpl = 'Error {code}: {msg}'
+        raise Exception(tmpl.format(code=code, msg=msg))
+
+    def __iter__(self):
+        return (Pod(node) for node in self.tree.findall('pod'))
+
+    def __len__(self):
+        return len(self.tree)
+
+    @property
+    def pods(self):
+        return list(iter(self))
+
+    @property
+    def results(self):
+        return (pod for pod in self if pod.title=='Result')
+
+class Pod(object):
+    def __init__(self, node):
+        self.node = node
+        self.__dict__.update(node.attrib)
+
+    def __iter__(self):
+        return (Content(node) for node in self.node.findall('subpod'))
+
+    @property
+    def main(self):
+        "The main content of this pod"
+        return next(iter(self))
+
+    @property
+    def text(self):
+        return self.main.text
+
+class Content(object):
+    def __init__(self, node):
+        self.node = node
+        self.__dict__.update(node.attrib)
+        self.text = node.find('plaintext').text
+
+class Client(object):
+    """
+    Wolfram|Alpha v2.0 client
+    """
+    def __init__(self, app_id):
+        self.app_id = app_id
+
+    def query(self, query):
+        """
+        Query Wolfram|Alpha with query using the v2.0 API
+        """
+        query = urllib.parse.urlencode(dict(
+            input=query,
+            appid=self.app_id,
+        ))
+        url = 'http://api.wolframalpha.com/v2/query?' + query
+        resp = urllib.request.urlopen(url)
+        assert resp.headers.get_content_type() == 'text/xml'
+        assert resp.headers.get_param('charset') == 'utf-8'
+        return Result(resp)
diff --git a/wolframalpha/compat.py b/wolframalpha/compat.py
new file mode 100644
index 0000000..be52d21
--- /dev/null
+++ b/wolframalpha/compat.py
@@ -0,0 +1,14 @@
+import six
+from six.moves import http_client
+
+def fix_HTTPMessage():
+	"""
+	Python 2 uses a deprecated method signature and doesn't provide the
+	forward compatibility.
+	Add it.
+	"""
+	if six.PY3:
+		return
+
+	http_client.HTTPMessage.get_content_type = http_client.HTTPMessage.gettype
+	http_client.HTTPMessage.get_param = http_client.HTTPMessage.getparam
diff --git a/wolframalpha/pmxbot.py b/wolframalpha/pmxbot.py
new file mode 100644
index 0000000..e9bdae0
--- /dev/null
+++ b/wolframalpha/pmxbot.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+from pmxbot.core import command
+
+import wolframalpha
+
+ at command("wolframalpha", aliases=('wa',), doc="Wolfram Alpha rules")
+def wa(client, event, channel, nick, rest):
+	client = wolframalpha.Client('Q59EW4-UEL27J79UK')
+	res = client.query(rest)
+	return next(res.results).text
diff --git a/wolframalpha/test_client.py b/wolframalpha/test_client.py
new file mode 100644
index 0000000..17b05b7
--- /dev/null
+++ b/wolframalpha/test_client.py
@@ -0,0 +1,22 @@
+#-*- coding: utf-8 -*-
+
+from __future__ import unicode_literals
+
+import pytest
+
+import wolframalpha
+
+app_id = 'Q59EW4-7K8AHE858R'
+"App ID for testing this project. Please don't use for other apps."
+
+def test_basic():
+	client = wolframalpha.Client(app_id)
+	res = client.query('30 deg C in deg F')
+	assert len(res.pods) > 0
+	results = list(res.results)
+	assert results[0].text == '86 °F  (degrees Fahrenheit)'
+
+def test_invalid_app_id():
+	client = wolframalpha.Client('abcdefg')
+	with pytest.raises(Exception):
+		client.query('30 deg C in deg F')

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/wolframalpha.git



More information about the Python-modules-commits mailing list