Skip to content

Commit 4bed134

Browse files
committed
Initial import.
0 parents  commit 4bed134

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+4772
-0
lines changed

.gitignore

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
5+
# C extensions
6+
*.so
7+
8+
# Distribution / packaging
9+
bin/
10+
build/
11+
develop-eggs/
12+
dist/
13+
eggs/
14+
lib/
15+
lib64/
16+
parts/
17+
sdist/
18+
var/
19+
*.egg-info/
20+
.installed.cfg
21+
*.egg
22+
23+
# Installer logs
24+
pip-log.txt
25+
pip-delete-this-directory.txt
26+
27+
# Unit test / coverage reports
28+
.tox/
29+
.coverage
30+
.cache
31+
nosetests.xml
32+
coverage.xml
33+
34+
# Translations
35+
*.mo
36+
37+
# Mr Developer
38+
.mr.developer.cfg
39+
.project
40+
.pydevproject
41+
42+
# Rope
43+
.ropeproject
44+
45+
# Django stuff:
46+
*.log
47+
*.pot
48+
49+
# Sphinx documentation
50+
docs/_build/
51+
52+
53+
*~
54+

LICENSE.txt

+674
Large diffs are not rendered by default.

README.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
Wpull
2+
=====
3+
4+
**Work in progress!**
5+
6+
Wpull is a Wget-compatible (or remake/clone/replacement/alternative) web downloader.
7+
8+
Features:
9+
10+
* Written in Python
11+
* Modular
12+
* Asynchronous
13+
14+
15+
Install
16+
-------
17+
18+
Requires:
19+
20+
* Python 3.2+
21+
* Tornado, toro, lxml
22+
23+
Dependencies can be installed using pip:
24+
25+
pip3 install -r requirements.txt
26+
27+
28+
Run
29+
---
30+
31+
To download the homepage of Google.com:
32+
33+
python3 -m wpull google.com
34+
35+
To see all options:
36+
37+
python3 -m wpull --help
38+
39+
40+
Todo
41+
----
42+
43+
* lot's of TODO markers in code
44+
* docstrings
45+
* 3to2 support
46+
47+
48+
Credits
49+
-------
50+
51+
Copyright 2013 by Christopher Foo. License GPL v3.
52+
53+
We would like to acknowledge the authors of GNU Wget as Wpull uses algorithms from Wget.
54+

requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
tornado=3.1.1
2+
toro=0.5
3+
lxml=3.1.0

setup.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python
2+
3+
from distutils.core import setup
4+
5+
import os.path
6+
import re
7+
from distutils.version import StrictVersion
8+
9+
10+
def get_version():
11+
path = os.path.join('wpull', 'version.py')
12+
13+
with open(path, 'r') as version_file:
14+
content = version_file.read()
15+
return re.match(r"__version__ = '(.+)'", content).group(1)
16+
17+
18+
version = get_version()
19+
20+
StrictVersion(version)
21+
22+
setup(name='wpull',
23+
version=version,
24+
description='Wget-compatible web downloader.',
25+
author='Christopher Foo',
26+
author_email='[email protected]',
27+
url='',
28+
packages=['wpull'],
29+
install_requires=['tornado', 'toro', 'lxml'],
30+
)

wpull/__init__.py

Whitespace-only changes.

wpull/__main__.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import sys
2+
import tornado.ioloop
3+
4+
from wpull.app import AppArgumentParser, build_engine
5+
6+
7+
if __name__ == '__main__':
8+
arg_parser = AppArgumentParser()
9+
args = arg_parser.parse_args()
10+
io_loop = tornado.ioloop.IOLoop.instance()
11+
engine = build_engine(args)
12+
exit_code = io_loop.run_sync(engine)
13+
sys.exit(exit_code)

wpull/actor.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
class Event(object):
2+
'''http://www.valuedlessons.com/2008/04/events-in-python.html'''
3+
def __init__(self):
4+
super().__init__()
5+
self.handlers = set()
6+
7+
def handle(self, handler):
8+
self.handlers.add(handler)
9+
return self
10+
11+
def unhandle(self, handler):
12+
try:
13+
self.handlers.remove(handler)
14+
except:
15+
raise ValueError("Handler is not handling this event, so cannot unhandle it.")
16+
return self
17+
18+
def fire(self, *args, **kargs):
19+
for handler in self.handlers:
20+
handler(*args, **kargs)
21+
22+
def get_handler_count(self):
23+
return len(self.handlers)
24+
25+
def clear(self):
26+
self.handlers.clear()
27+
28+
__iadd__ = handle
29+
__isub__ = unhandle
30+
__call__ = fire
31+
__len__ = get_handler_count

0 commit comments

Comments
 (0)