Skip to content

Commit 95d5d03

Browse files
committed
Remove junk from setup.py and rewrite blurb
1 parent 36ede70 commit 95d5d03

File tree

1 file changed

+34
-101
lines changed

1 file changed

+34
-101
lines changed

setup.py

Lines changed: 34 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -4,61 +4,33 @@
44
Stateful programmatic web browsing, after Andy Lester's Perl module
55
WWW::Mechanize.
66
7-
The library is layered: mechanize.Browser (stateful web browser),
8-
mechanize.UserAgent (configurable URL opener), plus urllib2 handlers.
9-
10-
Features include: ftp:, http: and file: URL schemes, browser history,
11-
high-level hyperlink and HTML form support, HTTP cookies, HTTP-EQUIV and
12-
Refresh, Referer [sic] header, robots.txt, redirections, proxies, and
13-
Basic and Digest HTTP authentication. mechanize's response objects are
14-
(lazily-) .seek()able and still work after .close().
15-
16-
Much of the code originally derived from Perl code by Gisle Aas
17-
(libwww-perl), Johnny Lee (MSIE Cookie support) and last but not least
18-
Andy Lester (WWW::Mechanize). urllib2 was written by Jeremy Hylton.
7+
mechanize.Browser implements the urllib2.OpenerDirectory interface. Browser
8+
objects have state, including navigation history, HTML form state, cookies,
9+
etc. The set of features and URL schemes handled by Browser objects is
10+
configurable. The library also provides an API that is mostly compatible with
11+
urllib2: your urllib2 program will likely still work if you replace "urllib2"
12+
with "mechanize" everywhere.
13+
14+
Features include: ftp:, http: and file: URL schemes, browser history, hyperlink
15+
and HTML form support, HTTP cookies, HTTP-EQUIV and Refresh, Referer [sic]
16+
header, robots.txt, redirections, proxies, and Basic and Digest HTTP
17+
authentication.
18+
19+
Much of the code originally derived from Perl code by Gisle Aas (libwww-perl),
20+
Johnny Lee (MSIE Cookie support) and last but not least Andy Lester
21+
(WWW::Mechanize). urllib2 was written by Jeremy Hylton.
1922
2023
"""
2124

22-
def unparse_version(tup):
23-
major, minor, bugfix, state_char, pre = tup
24-
fmt = "%s.%s.%s"
25-
args = [major, minor, bugfix]
26-
if state_char is not None:
27-
fmt += "%s"
28-
args.append(state_char)
29-
if pre is not None:
30-
fmt += "-pre%s"
31-
args.append(pre)
32-
return fmt % tuple(args)
33-
34-
def str_to_tuple(text):
35-
if text.startswith("("):
36-
text = text[1:-1]
37-
els = [el.strip() for el in text.split(",")]
38-
newEls = []
39-
for ii in range(len(els)):
40-
el = els[ii]
41-
if el == "None":
42-
newEls.append(None)
43-
elif 0 <= ii < 3:
44-
newEls.append(int(el))
45-
else:
46-
if el.startswith("'") or el.startswith('"'):
47-
el = el[1:-1]
48-
newEls.append(el)
49-
return tuple(newEls)
25+
try:
26+
import setuptools
27+
except ImportError:
28+
import ez_setup
29+
ez_setup.use_setuptools()
30+
import setuptools
5031

51-
import re
52-
## VERSION_MATCH = re.search(r'__version__ = \((.*)\)',
53-
## open("mechanize/_mechanize.py").read())
54-
## VERSION = unparse_version(str_to_tuple(VERSION_MATCH.group(1)))
5532
VERSION = "0.1.12"
56-
INSTALL_REQUIRES = ["ClientForm>=0.2.6, ==dev"]
57-
NAME = "mechanize"
58-
PACKAGE = True
59-
LICENSE = "BSD" # or ZPL 2.1
60-
PLATFORMS = ["any"]
61-
ZIP_SAFE = True
33+
6234
CLASSIFIERS = """\
6335
Development Status :: 5 - Production/Stable
6436
Intended Audience :: Developers
@@ -92,63 +64,24 @@ def str_to_tuple(text):
9264
Topic :: Text Processing :: Markup :: XML
9365
"""
9466

95-
#-------------------------------------------------------
96-
# the rest is constant for most of my released packages:
97-
98-
import sys
99-
100-
if PACKAGE:
101-
packages, py_modules = [NAME], None
102-
else:
103-
packages, py_modules = None, [NAME]
104-
105-
doclines = __doc__.split("\n")
106-
107-
if not hasattr(sys, "version_info") or sys.version_info < (2, 3):
108-
from distutils.core import setup
109-
_setup = setup
110-
def setup(**kwargs):
111-
for key in [
112-
# distutils >= Python 2.3 args
113-
# XXX probably download_url came in earlier than 2.3
114-
"classifiers", "download_url",
115-
# setuptools args
116-
"install_requires", "zip_safe", "test_suite",
117-
]:
118-
if kwargs.has_key(key):
119-
del kwargs[key]
120-
# Only want packages keyword if this is a package,
121-
# only want py_modules keyword if this is a single-file module,
122-
# so get rid of packages or py_modules keyword as appropriate.
123-
if kwargs["packages"] is None:
124-
del kwargs["packages"]
125-
else:
126-
del kwargs["py_modules"]
127-
apply(_setup, (), kwargs)
128-
else:
129-
import ez_setup
130-
ez_setup.use_setuptools()
131-
from setuptools import setup
132-
13367
def main():
134-
setup(
135-
name = NAME,
68+
setuptools.setup(
69+
name = "mechanize",
13670
version = VERSION,
137-
license = LICENSE,
138-
platforms = PLATFORMS,
71+
license = "BSD", # or ZPL 2.1
72+
platforms = ["any"],
13973
classifiers = [c for c in CLASSIFIERS.split("\n") if c],
140-
install_requires = INSTALL_REQUIRES,
141-
zip_safe = ZIP_SAFE,
74+
install_requires = ["ClientForm>=0.2.6, ==dev"],
75+
zip_safe = True,
14276
test_suite = "test",
14377
author = "John J. Lee",
14478
author_email = "jjl@pobox.com",
145-
description = doclines[0],
146-
long_description = "\n".join(doclines[2:]),
147-
url = "http://wwwsearch.sourceforge.net/%s/" % NAME,
148-
download_url = ("http://wwwsearch.sourceforge.net/%s/src/"
149-
"%s-%s.tar.gz" % (NAME, NAME, VERSION)),
150-
py_modules = py_modules,
151-
packages = packages,
79+
description = __doc__.split("\n", 1)[0],
80+
long_description = __doc__.split("\n", 2)[-1],
81+
url = "http://wwwsearch.sourceforge.net/mechanize/",
82+
download_url = ("http://wwwsearch.sourceforge.net/mechanize/src/"
83+
"mechanize-%s.tar.gz" % VERSION),
84+
packages = ["mechanize"],
15285
)
15386

15487

0 commit comments

Comments
 (0)