Changeset 297:0df29400e6b8
- Timestamp:
- 2007-08-31 18:14:37
(1 year ago)
- Author:
- Stefan Schwarzer <sschwarzer@sschwarzer.net>
- branch:
- default
- Message:
Made all imports relative (apart from those in the
`wsbrowser`/`wsbrowser.py` scripts, where they're necessary).
The former approach of using only absolute imports was kind of
cleaner, especially with respect to future Python versions. - However,
the absolute imports were also _very_ confusing (even for me) and
required a funny workaround for development if a Websourcebrowser
package was already installed somewhere in `sys.path`.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r291 |
r297 |
|
| 7 | 7 | config.py |
|---|
| 8 | 8 | converter.py |
|---|
| 9 | | ifdevel.py |
|---|
| 10 | 9 | pygmentsfinder.py |
|---|
| 11 | 10 | session.py |
|---|
| r289 |
r297 |
|
| 53 | 53 | Subversion_ and Mercurial_, and Vim_ swap files. |
|---|
| 54 | 54 | |
|---|
| 55 | | The second environment variable is ``WSB_DEVEL`` which is primarily |
|---|
| 56 | | interesting for Websourcebrowser developers. If set to 1, don't use an |
|---|
| 57 | | installed Websourcebrowser package but the directory |
|---|
| 58 | | ``websourcebrowser`` which has to be the current directory. |
|---|
| 59 | | |
|---|
| 60 | 55 | To get help for the command line options, invoke the installed program |
|---|
| 61 | 56 | with the ``help`` option:: |
|---|
| … | … | |
| 86 | 81 | Though it's recommended, you don't *have to* install Websourcebrowser. |
|---|
| 87 | 82 | Instead you can get away with extracting the source archive (see |
|---|
| 88 | | below), renaming the ``websourcebrowser-version`` directory to just |
|---|
| 89 | | ``websourcebrowser`` and adding the directory -- without the trailing |
|---|
| 90 | | ``websourcebrowser`` part -- to the ``PYTHONPATH`` environment |
|---|
| 91 | | variable. For example, if the directory is |
|---|
| 92 | | ``/home/me/downloads/websourcebrowser``, add ``/home/me/downloads`` to |
|---|
| | 83 | below) and adding the extracted directory to the ``PYTHONPATH`` |
|---|
| | 84 | environment variable. For example, if the directory is |
|---|
| | 85 | ``/home/me/downloads/websourcebrowser-0.2``, add that to |
|---|
| 93 | 86 | ``PYTHONPATH``. |
|---|
| 94 | 87 | |
|---|
| r292 |
r297 |
|
| 33 | 33 | import urlparse |
|---|
| 34 | 34 | |
|---|
| 35 | | from websourcebrowser import coding |
|---|
| 36 | | from websourcebrowser import config |
|---|
| 37 | | from websourcebrowser import converter |
|---|
| 38 | | from websourcebrowser import pygmentsfinder |
|---|
| 39 | | from websourcebrowser import session |
|---|
| 40 | | from websourcebrowser import template |
|---|
| 41 | | from websourcebrowser import urlpath |
|---|
| | 35 | # Websourcebrowser modules |
|---|
| | 36 | import coding |
|---|
| | 37 | import config |
|---|
| | 38 | import converter |
|---|
| | 39 | import pygmentsfinder |
|---|
| | 40 | import session |
|---|
| | 41 | import template |
|---|
| | 42 | import urlpath |
|---|
| 42 | 43 | |
|---|
| 43 | 44 | |
|---|
| r296 |
r297 |
|
| 31 | 31 | import sys |
|---|
| 32 | 32 | |
|---|
| 33 | | from websourcebrowser import coding |
|---|
| 34 | | from websourcebrowser import tools |
|---|
| | 33 | # Websourcebrowser modules |
|---|
| | 34 | import coding |
|---|
| | 35 | import tools |
|---|
| 35 | 36 | |
|---|
| 36 | 37 | # |
|---|
| r296 |
r297 |
|
| 33 | 33 | import sys |
|---|
| 34 | 34 | |
|---|
| 35 | | from websourcebrowser import coding |
|---|
| 36 | | from websourcebrowser import config |
|---|
| 37 | | from websourcebrowser import pygmentsfinder |
|---|
| 38 | | from websourcebrowser import session |
|---|
| 39 | | from websourcebrowser import tools |
|---|
| 40 | | from websourcebrowser import urlpath |
|---|
| | 35 | # Websourcebrowser modules |
|---|
| | 36 | import coding |
|---|
| | 37 | import config |
|---|
| | 38 | import pygmentsfinder |
|---|
| | 39 | import session |
|---|
| | 40 | import tools |
|---|
| | 41 | import urlpath |
|---|
| 41 | 42 | |
|---|
| 42 | 43 | |
|---|
| r270 |
r297 |
|
| 25 | 25 | import sys |
|---|
| 26 | 26 | |
|---|
| 27 | | # has to come first |
|---|
| 28 | | from websourcebrowser import ifdevel |
|---|
| 29 | | del sys.modules['websourcebrowser'] |
|---|
| 30 | | |
|---|
| | 27 | # for development, invoke file `browser.py` directly |
|---|
| 31 | 28 | from websourcebrowser import browser |
|---|
| 32 | 29 | |
|---|
| r280 |
r297 |
|
| 26 | 26 | import urlparse |
|---|
| 27 | 27 | |
|---|
| 28 | | from websourcebrowser import coding |
|---|
| 29 | | from websourcebrowser import config |
|---|
| | 28 | # Websourcebrowser modules |
|---|
| | 29 | import coding |
|---|
| | 30 | import config |
|---|
| 30 | 31 | |
|---|
| 31 | 32 | |
|---|
| r270 |
r297 |
|
| 34 | 34 | del sys.modules['websourcebrowser'] |
|---|
| 35 | 35 | |
|---|
| 36 | | # modules that are part of Websourcebrowser |
|---|
| 37 | | from websourcebrowser import coding |
|---|
| 38 | | from websourcebrowser import config |
|---|
| 39 | | from websourcebrowser import converter |
|---|
| 40 | | from websourcebrowser import session |
|---|
| 41 | | from websourcebrowser import urlpath |
|---|
| | 36 | # Websourcebrowser modules |
|---|
| | 37 | import coding |
|---|
| | 38 | import config |
|---|
| | 39 | import converter |
|---|
| | 40 | import session |
|---|
| | 41 | import urlpath |
|---|
| 42 | 42 | |
|---|
| 43 | 43 | |
|---|
| r295 |
r297 |
|
| 17 | 17 | path. The following tests are intended to run under Posix systems:: |
|---|
| 18 | 18 | |
|---|
| 19 | | >>> from websourcebrowser import converter |
|---|
| | 19 | >>> import converter |
|---|
| 20 | 20 | |
|---|
| 21 | 21 | >>> converter.dir_level("/the/root/directory") |
|---|
| … | … | |
| 76 | 76 | value of ``config.ignore_patterns`` which is a list of glob patterns:: |
|---|
| 77 | 77 | |
|---|
| 78 | | >>> from websourcebrowser import config |
|---|
| | 78 | >>> import config |
|---|
| 79 | 79 | >>> config.ignore_patterns = ["*.pyc", "*.swp"] |
|---|
| 80 | 80 | >>> for item in ("file.py", "file.pyc", "test.swpx", "test.swp"): |
|---|
| r277 |
r297 |
|
| 10 | 10 | a dictionary with the parameters from the query string of the URL. |
|---|
| 11 | 11 | |
|---|
| 12 | | >>> from websourcebrowser import session |
|---|
| | 12 | >>> import session |
|---|
| 13 | 13 | |
|---|
| 14 | 14 | Testing the constructor |
|---|
| r260 |
r297 |
|
| 9 | 9 | So, let's begin: |
|---|
| 10 | 10 | |
|---|
| 11 | | >>> from websourcebrowser import urlpath |
|---|
| | 11 | >>> import urlpath |
|---|
| 12 | 12 | |
|---|
| 13 | 13 | Testing the ``is_safe_path`` function |
|---|
| r260 |
r297 |
|
| 9 | 9 | So, let's begin: |
|---|
| 10 | 10 | |
|---|
| 11 | | >>> from websourcebrowser import urlpath |
|---|
| | 11 | >>> import urlpath |
|---|
| 12 | 12 | |
|---|
| 13 | 13 | Testing the ``is_safe_path`` function |
|---|
| r286 |
r297 |
|
| 33 | 33 | - write tutorial? |
|---|
| 34 | 34 | |
|---|
| | 35 | - re-think supporting a configuration file |
|---|
| 35 | 36 | - improve running Websourcebrowser without installation |
|---|
| 36 | 37 | - rename parameter "dir_levels" to "dir_level" where appropriate |
|---|
| … | … | |
| 46 | 47 | archive) |
|---|
| 47 | 48 | |
|---|
| 48 | | - restrict access to certain source IPs or address ranges (default |
|---|
| 49 | | should be only localhost) |
|---|
| 50 | 49 | - prevent DOS attacks |
|---|
| 51 | 50 | - limit size of displayed files, especially binary files displayed |
|---|
| r291 |
r297 |
|
| 26 | 26 | import urllib |
|---|
| 27 | 27 | |
|---|
| 28 | | from websourcebrowser import tools |
|---|
| | 28 | # Websourcebrowser modules |
|---|
| | 29 | import tools |
|---|
| 29 | 30 | |
|---|
| 30 | 31 | |
|---|