Skip to content
This repository has been archived by the owner on Dec 9, 2020. It is now read-only.

Work in Progress #1

Merged
merged 19 commits into from
May 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ coverage.xml
# Sphinx documentation
docs/_build/

# epydoc output
html/
epydocs/

# IntelliJ IDEA Project Files
.idea/*
.iml
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: python
python:
- 'pypy'
- '2.7'
install:
- pip install .
script:
Expand Down
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,33 @@ default: test run-example

WARGS = -W default::Warning

run-example: install-dependencies
run-example: install-dependencies PHONY
python $(WARGS) examples/chat.py

run-web-example: install-dependencies
run-web-example: install-dependencies PHONY
python $(WARGS) examples/web_viewer.py

test: install-dependencies
test: install-dependencies PHONY
python $(WARGS) -m pytest

test-coverage: install-dependencies
test-coverage: install-dependencies PHONY
python -m coverage run --branch -m pytest
python -m coverage report --include 'chatexchange/*'

install-dependencies:
install-dependencies: PHONY
# This also creates a link to `chatexchange/` in the Python
# environment, which is neccessary for the other files to be
# able to find it.
rm -rf src/*.egg-info
pip install -e .

clean:
epydocs: PHONY
epydoc chatexchange --html -o epydocs \
--top ChatExchange.chatexchange --no-frames --no-private --verbose

clean: PHONY
rm -rf src/*.egg-info
find . -type f -name '*.pyc' -delete
find . -type d -name '__pycache__' -delete

PHONY:
8 changes: 8 additions & 0 deletions chatexchange/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
from . import browser

from . import users
from . import messages
from . import rooms
from . import events
from . import client


Browser = browser.Browser

Client = client.Client

__all__ = [
'browser', 'users', 'messages', 'rooms', 'events', 'client',
'Browser', 'Client']
19 changes: 19 additions & 0 deletions chatexchange/_utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
# encoding: utf-8
from HTMLParser import HTMLParser
import functools
import htmlentitydefs
import logging
import weakref


def log_and_ignore_exceptions(
f, exceptions=Exception, logger=logging.getLogger('exceptions')
):
"""
Wraps a function to catch its exceptions, log them, and return None.
"""
@functools.wraps(f)
def wrapper(*a, **kw):
try:
return f(*a, **kw)
except exceptions:
logger.exception("ignored unhandled exception in %s", f)
return None

return wrapper


class HTMLTextExtractor(HTMLParser):
# Originally posted at http://stackoverflow.com/a/7778368.
# by Søren Løvborg (http://stackoverflow.com/u/13679) and Eloff.
Expand Down
Loading