Skip to content
This repository

Unbundle external libraries #191

Merged
merged 6 commits into from over 3 years ago

5 participants

Thomas Spura Brian E. Granger Fernando Perez Thomas Kluyver Toshio Kuratomi
Thomas Spura

This pull request contains an update to a new argparse and the unbundling of the libraries and nothing else anymore ( as requested )...

I read something on the mailing list about "git commit --amend" and to add the # of this pull request, so github will automatically close this.

Are there some notes how exactly that should look like? Or what exactly should I add there with --amend?

Brian E. Granger
Owner

I ran the test suite and looked through the code. I like this approach and the changes are clean, I think this is ready to go. But I know Fernando had been following this one closely, so I want him to at least look over this.

Fernando Perez
Owner

I also re-ran the test suite both in normal and in installed mode, and it worked fine, so it's pretty much ready to go in. I was about to push though, when I saw that pexpect was left behind without being unbundled. Any particular reason for this? I figured you'd want to unbundle all of externals if possible, no? I'll hold off on the merge/push until you have a chance to let us know why pexpect was separate, or make one more commit that takes care of it.

Once the pexpect question is settled, it's good to go. Thanks!

Thomas Spura

I did the unbundling before pexpat was introduced, so I simply missed it.... ;-)

Thanks, for the notice.

Fernando Perez
Owner

Tom, I'm afraid there are errors left. Once I try to merge your branch into trunk and run the test suite, I get:

Ran 9 test groups in 54.978s

Status:
ERROR - 2 out of 9 test groups failed.
----------------------------------------
Runner failed: IPython.core
You may wish to rerun this one individually, with:
/usr/bin/python /home/fperez/usr/lib/python2.6/site-packages/IPython/testing/iptest.py IPython.core

----------------------------------------
Runner failed: IPython.lib
You may wish to rerun this one individually, with:
/usr/bin/python /home/fperez/usr/lib/python2.6/site-packages/IPython/testing/iptest.py IPython.lib

Here's the full tracebacks:

iptest IPython.core:
...

======================================================================
ERROR: IPython.core.tests.test_formatters.test_pretty
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/nose/case.py", line 183, in runTest
    self.test(*self.arg)
  File "/home/fperez/usr/lib/python2.6/site-packages/IPython/core/tests/test_formatters.py", line 21, in test_pretty
    f.for_type(A, foo_printer)
  File "/home/fperez/usr/lib/python2.6/site-packages/IPython/core/formatters.py", line 126, in for_type
    oldfunc = self.type_pprinters.get(typ, None)
  File "/home/fperez/usr/lib/python2.6/site-packages/IPython/utils/traitlets.py", line 283, in __get__
    value = self.dynamic_initializer(obj)
  File "/home/fperez/usr/lib/python2.6/site-packages/IPython/core/formatters.py", line 90, in _type_pprinters_default
    return pretty._type_pprinters.copy()
AttributeError: 'module' object has no attribute '_type_pprinters'

----------------------------------------------------------------------
Ran 267 tests in 1.844s

FAILED (SKIP=1, errors=1)

and

dreamweaver[junk]> iptest IPython.lib
======================================================================
FAIL: Test the IPython runner.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/fperez/usr/lib/python2.6/site-packages/IPython/lib/tests/test_irunner.py", line 122, in testIPython
    self._test_runner(runner,source,output)
  File "/home/fperez/usr/lib/python2.6/site-packages/IPython/lib/tests/test_irunner.py", line 36, in _test_runner
    self.fail('mismatch in number of lines')
AssertionError: mismatch in number of lines
    """Fail immediately, with the given message."""
>>  raise self.failureException, 'mismatch in number of lines'
    

----------------------------------------------------------------------
Ran 6 tests in 1.200s

FAILED (failures=1)

Once the tests pass, I'll be happy to merge it, but you should always make sure that the test suite passes not only with your branch alone, but once merged, since that's what the reviewers will be testing. Passing on your branch alone isn't sufficient, because what goes into the project ultimately is the merge of your branch into trunk, so that's what must pass the test suite before we can accept it.

Thomas Spura

Both are because pretty seems to have changed some functions, so updating could solve this (I'll have a look)...

But thanks for noticing. Right now running the testsuite everytime, won't help here to detect little errors like that, because I have to many failing tests right now (the old fedora problem, whyever...).
I hope to further look around in ipython, to get more knowledge, to finally fix them all, but not right now.... :-(

Thomas Spura

The problem is that the pretty.py from ipython differs too much from the upstream pretty.

Till upstream has the needed changes, it would be best, to not unbundle pretty, because it's not possible right now.
The not unbundling happens now in the commit above, but I have here:
FAILED (SKIP=1, failures=2) all from Ipython.core, seem to be the usual fedora failures...

Brian E. Granger
Owner

What is the status of this pull request?

Thomas Spura

I need to wait for someone else to run the testsuite, because the fedora one is broken slightly, which is kind of expected (and I don't know why).

After this pull, everything except pretty is unbundled, and pretty can't be unbundled, because it differs to much from upstream...

At least anything else would be ok then.

Brian E. Granger
Owner

If pretty is really our own version now, we should move it to the lib subpackage. That way everything in externals will have upstream versions available.

Thomas Spura

It differs too much, that it can be patched somehow, but I don't know if you maybe want to get the changes into upstream...

The biggest changes are in 428050f

I did the rename now and you can choose, which way to go :)

Thomas Kluyver takluyver commented on the diff
IPython/external/argparse/__init__.py
... ... @@ -0,0 +1,12 @@
  1 +try:
  2 + import argparse
  3 + # Workaround an argparse bug, FIXED in argparse 1.1.0
  4 + if 'RawTextHelpFormatterArgumentDefaultsHelpFormatter' in argparse.__all__:
  5 + import itertools
  6 + argparse.__all__ = list(itertools.chain( [i for i in argparse.__all__
  7 + if i != 'RawTextHelpFormatterArgumentDefaultsHelpFormatter'],
  8 + ['RawTextHelpFormatter', 'ArgumentDefaultsHelpFormatter']))
8
Thomas Kluyver Collaborator
takluyver added a note

Is it necessary to use itertools.chain here, rather than just [i for i in ...] + [a, b]?

Toshio Kuratomi
abadger added a note

I wrote the patch originally so tomspur asked me to comment.

AFAICT, there's no reason that the simpler method shouldn't work:

argparse.__all__ = ([i for i in argparse.__all__ 
        if i != 'RawTextHelpFormatterArgumentDefaultsHelpFormatter']
        +  ['RawTextHelpFormatter', 'ArgumentDefaultsHelpFormatter'])

itertools.chain seems like something I'd do while thinking things through and then fail to see that it was unnecessary when submitting the final patch.

Thomas Kluyver Collaborator
takluyver added a note

OK, smashing. It just stood out when I was scanning through. Thomas, since it's in your branch, do you want to tweak that? We'll run the tests again, and hopefully it's good to go (unless anyone else sees a reason why not - speak now or forever hold your peace, and all that).

Thomas Spura
tomspur added a note

I'd leave it like it is.
itertools is a std python lib, so it doesn't add any dependency, so it's ok to use it.
When argparse 1.1.0 is common in all main linux distros, we can simply delete the workaround again.
(And I guess it might be the time right now... Debian, Ubuntu and Fedora has the 1.1. in the repositories, if I see that right (can only be sure for Fedora))

Thomas Kluyver Collaborator
takluyver added a note

Ubuntu seems to have 1.1.1 as of Lucid (the release before the current one), which is the first time it packaged it at all. The same version is in Debian stable (they had a new release recently). It looks like macports has 1.1 as well. Assuming the version that's in the stdlib for Python 2.7 and Python 3.2 doesn't have the bug, I think it's safe to remove the workaround.

Toshio Kuratomi
abadger added a note

The EPEL repositories for RHEL 6 have argparse-1.0.1 so I wouldn't characterize it as "safe" to remove. OTOH, argparse-1.1.x looks API compatible so we might be able to upgrade the EPEL packages to a newer version where necessary to get a newer ipython. Definitely a judgement call.

Thomas Kluyver Collaborator
takluyver added a note

But is IPython 0.11 (not even released yet) likely to be put onto that platform? I wouldn't make the assumption in the 0.10 series, but I don't think it's unreasonable for the next version of IPython to depend on a version of a package that's been out for at least a year.

Toshio Kuratomi
abadger added a note

tomspur might have a more definite answer since he's involved with maintaining ipython in fedora (on which the EPEL packages are based) -- all I can say for sure is that there's not yet an ipython package for EPEL6 and because users like to get the most recent versions, we generally give them the most recent version at the time that someone steps up to branch and maintain the initial package for that release. Oh, and of course, if users are running RHEL as their workstation (as opposed to a server) they may want to install the latest versions of ipython themselves rather than using what the distro and EPEL provide so they might want to install ipython-0.11 on RHEL5 even.... like I say, though, that could be a case where the EPEL maintainers could be convinced to update argparse to a later version if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Fernando Perez
Owner

Hey tomspur, sorry this has taken so long to get right... But right now it doesn't even apply on top of master:

(tomspur-ready_unbundle)amirbar[ipython]> git pull https://github.com/tomspur/ipython.git ready_unbundle 
remote: Counting objects: 69, done.
remote: Compressing objects: 100% (48/48), done.
remote: Total 62 (delta 22), reused 52 (delta 14)
Unpacking objects: 100% (62/62), done.
From https://github.com/tomspur/ipython
 * branch            ready_unbundle -> FETCH_HEAD
Auto-merging IPython/core/formatters.py
CONFLICT (content): Merge conflict in IPython/core/formatters.py
Automatic merge failed; fix conflicts and then commit the result.

If you can rebase it so it applies cleanly on top of master, we'll try to finish up any remaining questions with this branch and merge it before it goes stale again.

tomspur added some commits
Thomas Spura tomspur Unbundle of all external modules.
Move all libraries in external into subfolders and place a custom
__init__.py into each of them. This way the system installed ones are
tried first, before falling back to the bundled ones.

Now every distribution can properly depend on the upstream library.
(e.g. bundled libraries are not allowed in fedora)

Signed-off-by: Toshio Ernie Kuratomi <toshio@fedoraproject.org>
Signed-off-by: Thomas Spura <tomspur@fedoraproject.org>
261328d
Thomas Spura tomspur Update internal argparse to version 1.1
Signed-off-by: Thomas Spura <tomspur@fedoraproject.org>
994a729
Thomas Spura tomspur Also unbundle pexpect
Signed-off-by: Thomas Spura <tomspur@fedoraproject.org>
21647ae
Thomas Spura tomspur Don't use the system pretty...
... because upstream pretty does not (yet?) incorporate the changes to
the local _pretty.

Signed-off-by: Thomas Spura <tomspur@fedoraproject.org>
67f9fe7
Thomas Spura tomspur import from module and not from module.py
Thanks to Justin Riley for noticing.

Signed-off-by: Thomas Spura <tomspur@fedoraproject.org>
b390cc3
Thomas Spura tomspur Move pretty into lib, because it's heavily changed now. 664ecc2
Thomas Spura

Hi fperez,
it should work again.

You still need to decide, if you want to pull the last commit "Move pretty into lib" or if you want to push the changes to pretty back to upstream.

Greetings,
Tom

Fernando Perez fperez merged commit 664ecc2 into from
Fernando Perez fperez closed this
Damián Avila damianavila referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 6 unique commits by 1 author.

Mar 13, 2011
Thomas Spura tomspur Unbundle of all external modules.
Move all libraries in external into subfolders and place a custom
__init__.py into each of them. This way the system installed ones are
tried first, before falling back to the bundled ones.

Now every distribution can properly depend on the upstream library.
(e.g. bundled libraries are not allowed in fedora)

Signed-off-by: Toshio Ernie Kuratomi <toshio@fedoraproject.org>
Signed-off-by: Thomas Spura <tomspur@fedoraproject.org>
261328d
Thomas Spura tomspur Update internal argparse to version 1.1
Signed-off-by: Thomas Spura <tomspur@fedoraproject.org>
994a729
Thomas Spura tomspur Also unbundle pexpect
Signed-off-by: Thomas Spura <tomspur@fedoraproject.org>
21647ae
Thomas Spura tomspur Don't use the system pretty...
... because upstream pretty does not (yet?) incorporate the changes to
the local _pretty.

Signed-off-by: Thomas Spura <tomspur@fedoraproject.org>
67f9fe7
Thomas Spura tomspur import from module and not from module.py
Thanks to Justin Riley for noticing.

Signed-off-by: Thomas Spura <tomspur@fedoraproject.org>
b390cc3
Thomas Spura tomspur Move pretty into lib, because it's heavily changed now. 664ecc2
This page is out of date. Refresh to see the latest.

Showing 28 changed files with 135 additions and 79 deletions. Show diff stats Hide diff stats

  1. +1 1  IPython/core/formatters.py
  2. 0  IPython/external/{Itpl.py → Itpl/_Itpl.py}
  3. +4 0 IPython/external/Itpl/__init__.py
  4. +12 0 IPython/external/argparse/__init__.py
  5. +58 76 IPython/external/{argparse.py → argparse/_argparse.py}
  6. +4 0 IPython/external/configobj/__init__.py
  7. 0  IPython/external/{configobj.py → configobj/_configobj.py}
  8. +8 0 IPython/external/decorator/__init__.py
  9. 0  IPython/external/{decorator.py → decorator/_decorator.py}
  10. +4 0 IPython/external/decorators/__init__.py
  11. 0  IPython/external/{decorators.py → decorators/_decorators.py}
  12. 0  IPython/external/{ → decorators}/_numpy_testing_utils.py
  13. +4 0 IPython/external/guid/__init__.py
  14. 0  IPython/external/{guid.py → guid/_guid.py}
  15. +4 0 IPython/external/mglob/__init__.py
  16. +0 2  IPython/external/{mglob.py → mglob/_mglob.py}
  17. +4 0 IPython/external/path/__init__.py
  18. 0  IPython/external/{path.py → path/_path.py}
  19. +5 0 IPython/external/pexpect/__init__.py
  20. 0  IPython/external/{pexpect.py → pexpect/_pexpect.py}
  21. +4 0 IPython/external/pyparsing/__init__.py
  22. 0  IPython/external/{pyparsing.py → pyparsing/_pyparsing.py}
  23. +4 0 IPython/external/simplegeneric/__init__.py
  24. 0  IPython/external/{simplegeneric.py → simplegeneric/_simplegeneric.py}
  25. +8 0 IPython/external/validate/__init__.py
  26. 0  IPython/external/{validate.py → validate/_validate.py}
  27. 0  IPython/{external → lib}/pretty.py
  28. +11 0 setupbase.py
2  IPython/core/formatters.py
@@ -27,7 +27,7 @@
27 27
28 28 # Our own imports
29 29 from IPython.config.configurable import Configurable
30   -from IPython.external import pretty
  30 +from IPython.lib import pretty
31 31 from IPython.utils.traitlets import Bool, Dict, Int, Str, CStr
32 32
33 33
0  IPython/external/Itpl.py → IPython/external/Itpl/_Itpl.py
File renamed without changes
4 IPython/external/Itpl/__init__.py
... ... @@ -0,0 +1,4 @@
  1 +try:
  2 + from Itpl import *
  3 +except ImportError:
  4 + from _Itpl import *
12 IPython/external/argparse/__init__.py
... ... @@ -0,0 +1,12 @@
  1 +try:
  2 + import argparse
  3 + # Workaround an argparse bug, FIXED in argparse 1.1.0
  4 + if 'RawTextHelpFormatterArgumentDefaultsHelpFormatter' in argparse.__all__:
  5 + import itertools
  6 + argparse.__all__ = list(itertools.chain( [i for i in argparse.__all__
  7 + if i != 'RawTextHelpFormatterArgumentDefaultsHelpFormatter'],
  8 + ['RawTextHelpFormatter', 'ArgumentDefaultsHelpFormatter']))
  9 + argparse.__all__.append('SUPPRESS')
  10 + from argparse import *
  11 +except ImportError:
  12 + from _argparse import *
134 IPython/external/argparse.py → IPython/external/argparse/_argparse.py
... ... @@ -1,18 +1,4 @@
1   -# -*- coding: utf-8 -*-
2   -
3   -# Copyright © 2006-2009 Steven J. Bethard <steven.bethard@gmail.com>.
4   -#
5   -# Licensed under the Apache License, Version 2.0 (the "License"); you may not
6   -# use this file except in compliance with the License. You may obtain a copy
7   -# of the License at
8   -#
9   -# http://www.apache.org/licenses/LICENSE-2.0
10   -#
11   -# Unless required by applicable law or agreed to in writing, software
12   -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13   -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14   -# License for the specific language governing permissions and limitations
15   -# under the License.
  1 +# Author: Steven J. Bethard <steven.bethard@gmail.com>.
16 2
17 3 """Command-line parsing library
18 4
@@ -75,7 +61,7 @@
75 61 still considered an implementation detail.)
76 62 """
77 63
78   -__version__ = '1.1a1'
  64 +__version__ = '1.1'
79 65 __all__ = [
80 66 'ArgumentParser',
81 67 'ArgumentError',
@@ -97,40 +83,10 @@
97 83
98 84 from gettext import gettext as _
99 85
100   -try:
101   - _set = set
102   -except NameError:
103   - from sets import Set as _set
104   -
105   -try:
106   - _basestring = basestring
107   -except NameError:
108   - _basestring = str
109   -
110   -try:
111   - _sorted = sorted
112   -except NameError:
113   -
114   - def _sorted(iterable, reverse=False):
115   - result = list(iterable)
116   - result.sort()
117   - if reverse:
118   - result.reverse()
119   - return result
120   -
121 86
122 87 def _callable(obj):
123 88 return hasattr(obj, '__call__') or hasattr(obj, '__bases__')
124 89
125   -# silence Python 2.6 buggy warnings about Exception.message
126   -if _sys.version_info[:2] == (2, 6):
127   - import warnings
128   - warnings.filterwarnings(
129   - action='ignore',
130   - message='BaseException.message has been deprecated as of Python 2.6',
131   - category=DeprecationWarning,
132   - module='argparse')
133   -
134 90
135 91 SUPPRESS = '==SUPPRESS=='
136 92
@@ -163,7 +119,7 @@ def __repr__(self):
163 119 return '%s(%s)' % (type_name, ', '.join(arg_strings))
164 120
165 121 def _get_kwargs(self):
166   - return _sorted(self.__dict__.items())
  122 + return sorted(self.__dict__.items())
167 123
168 124 def _get_args(self):
169 125 return []
@@ -416,7 +372,7 @@ def get_lines(parts, indent, prefix=None):
416 372
417 373 def _format_actions_usage(self, actions, groups):
418 374 # find group indices and identify actions in groups
419   - group_actions = _set()
  375 + group_actions = set()
420 376 inserts = {}
421 377 for group in groups:
422 378 try:
@@ -486,7 +442,7 @@ def _format_actions_usage(self, actions, groups):
486 442 parts.append(part)
487 443
488 444 # insert things at the necessary indices
489   - for i in _sorted(inserts, reverse=True):
  445 + for i in sorted(inserts, reverse=True):
490 446 parts[i:i] = [inserts[i]]
491 447
492 448 # join all the action items with spaces
@@ -621,6 +577,9 @@ def _expand_help(self, action):
621 577 for name in list(params):
622 578 if params[name] is SUPPRESS:
623 579 del params[name]
  580 + for name in list(params):
  581 + if hasattr(params[name], '__name__'):
  582 + params[name] = params[name].__name__
624 583 if params.get('choices') is not None:
625 584 choices_str = ', '.join([str(c) for c in params['choices']])
626 585 params['choices'] = choices_str
@@ -1028,7 +987,7 @@ def __init__(self,
1028 987 version=None,
1029 988 dest=SUPPRESS,
1030 989 default=SUPPRESS,
1031   - help=None):
  990 + help="show program's version number and exit"):
1032 991 super(_VersionAction, self).__init__(
1033 992 option_strings=option_strings,
1034 993 dest=dest,
@@ -1169,7 +1128,10 @@ class Namespace(_AttributeHolder):
1169 1128 """
1170 1129
1171 1130 def __init__(self, **kwargs):
1172   - self.__dict__.update(**kwargs)
  1131 + for name in kwargs:
  1132 + setattr(self, name, kwargs[name])
  1133 +
  1134 + __hash__ = None
1173 1135
1174 1136 def __eq__(self, other):
1175 1137 return vars(self) == vars(other)
@@ -1296,6 +1258,12 @@ def add_argument(self, *args, **kwargs):
1296 1258 if not _callable(action_class):
1297 1259 raise ValueError('unknown action "%s"' % action_class)
1298 1260 action = action_class(**kwargs)
  1261 +
  1262 + # raise an error if the action type is not callable
  1263 + type_func = self._registry_get('type', action.type, action.type)
  1264 + if not _callable(type_func):
  1265 + raise ValueError('%r is not callable' % type_func)
  1266 +
1299 1267 return self._add_action(action)
1300 1268
1301 1269 def add_argument_group(self, *args, **kwargs):
@@ -1393,12 +1361,6 @@ def _get_optional_kwargs(self, *args, **kwargs):
1393 1361 option_strings = []
1394 1362 long_option_strings = []
1395 1363 for option_string in args:
1396   - # error on one-or-fewer-character option strings
1397   - if len(option_string) < 2:
1398   - msg = _('invalid option string %r: '
1399   - 'must be at least two characters long')
1400   - raise ValueError(msg % option_string)
1401   -
1402 1364 # error on strings that don't start with an appropriate prefix
1403 1365 if not option_string[0] in self.prefix_chars:
1404 1366 msg = _('invalid option string %r: '
@@ -1406,18 +1368,12 @@ def _get_optional_kwargs(self, *args, **kwargs):
1406 1368 tup = option_string, self.prefix_chars
1407 1369 raise ValueError(msg % tup)
1408 1370
1409   - # error on strings that are all prefix characters
1410   - if not (_set(option_string) - _set(self.prefix_chars)):
1411   - msg = _('invalid option string %r: '
1412   - 'must contain characters other than %r')
1413   - tup = option_string, self.prefix_chars
1414   - raise ValueError(msg % tup)
1415   -
1416 1371 # strings starting with two prefix characters are long options
1417 1372 option_strings.append(option_string)
1418 1373 if option_string[0] in self.prefix_chars:
1419   - if option_string[1] in self.prefix_chars:
1420   - long_option_strings.append(option_string)
  1374 + if len(option_string) > 1:
  1375 + if option_string[1] in self.prefix_chars:
  1376 + long_option_strings.append(option_string)
1421 1377
1422 1378 # infer destination, '--foo-bar' -> 'foo_bar' and '-x' -> 'x'
1423 1379 dest = kwargs.pop('dest', None)
@@ -1427,6 +1383,9 @@ def _get_optional_kwargs(self, *args, **kwargs):
1427 1383 else:
1428 1384 dest_option_string = option_strings[0]
1429 1385 dest = dest_option_string.lstrip(self.prefix_chars)
  1386 + if not dest:
  1387 + msg = _('dest= is required for options like %r')
  1388 + raise ValueError(msg % option_string)
1430 1389 dest = dest.replace('-', '_')
1431 1390
1432 1391 # return the updated keyword arguments
@@ -1542,7 +1501,6 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
1542 1501 - usage -- A usage message (default: auto-generated from arguments)
1543 1502 - description -- A description of what the program does
1544 1503 - epilog -- Text following the argument descriptions
1545   - - version -- Add a -v/--version option with the given version string
1546 1504 - parents -- Parsers whose arguments should be copied into this one
1547 1505 - formatter_class -- HelpFormatter class for printing help messages
1548 1506 - prefix_chars -- Characters that prefix optional arguments
@@ -1567,6 +1525,14 @@ def __init__(self,
1567 1525 conflict_handler='error',
1568 1526 add_help=True):
1569 1527
  1528 + if version is not None:
  1529 + import warnings
  1530 + warnings.warn(
  1531 + """The "version" argument to ArgumentParser is deprecated. """
  1532 + """Please use """
  1533 + """"add_argument(..., action='version', version="N", ...)" """
  1534 + """instead""", DeprecationWarning)
  1535 +
1570 1536 superinit = super(ArgumentParser, self).__init__
1571 1537 superinit(description=description,
1572 1538 prefix_chars=prefix_chars,
@@ -1708,7 +1674,7 @@ def parse_known_args(self, args=None, namespace=None):
1708 1674 if not hasattr(namespace, action.dest):
1709 1675 if action.default is not SUPPRESS:
1710 1676 default = action.default
1711   - if isinstance(action.default, _basestring):
  1677 + if isinstance(action.default, basestring):
1712 1678 default = self._get_value(action, default)
1713 1679 setattr(namespace, action.dest, default)
1714 1680
@@ -1768,8 +1734,8 @@ def _parse_known_args(self, arg_strings, namespace):
1768 1734 arg_strings_pattern = ''.join(arg_string_pattern_parts)
1769 1735
1770 1736 # converts arg strings to the appropriate and then takes the action
1771   - seen_actions = _set()
1772   - seen_non_default_actions = _set()
  1737 + seen_actions = set()
  1738 + seen_non_default_actions = set()
1773 1739
1774 1740 def take_action(action, argument_strings, option_string=None):
1775 1741 seen_actions.add(action)
@@ -1973,7 +1939,10 @@ def _read_args_from_files(self, arg_strings):
1973 1939 try:
1974 1940 args_file = open(arg_string[1:])
1975 1941 try:
1976   - arg_strings = args_file.read().splitlines()
  1942 + arg_strings = []
  1943 + for arg_line in args_file.read().splitlines():
  1944 + for arg in self.convert_arg_line_to_args(arg_line):
  1945 + arg_strings.append(arg)
1977 1946 arg_strings = self._read_args_from_files(arg_strings)
1978 1947 new_arg_strings.extend(arg_strings)
1979 1948 finally:
@@ -1985,6 +1954,9 @@ def _read_args_from_files(self, arg_strings):
1985 1954 # return the modified argument list
1986 1955 return new_arg_strings
1987 1956
  1957 + def convert_arg_line_to_args(self, arg_line):
  1958 + return [arg_line]
  1959 +
1988 1960 def _match_argument(self, action, arg_strings_pattern):
1989 1961 # match the pattern for this action to the arg strings
1990 1962 nargs_pattern = self._get_nargs_pattern(action)
@@ -2029,15 +2001,15 @@ def _parse_optional(self, arg_string):
2029 2001 if not arg_string[0] in self.prefix_chars:
2030 2002 return None
2031 2003
2032   - # if it's just dashes, it was meant to be positional
2033   - if not arg_string.strip('-'):
2034   - return None
2035   -
2036 2004 # if the option string is present in the parser, return the action
2037 2005 if arg_string in self._option_string_actions:
2038 2006 action = self._option_string_actions[arg_string]
2039 2007 return action, arg_string, None
2040 2008
  2009 + # if it's just a single character, it was meant to be positional
  2010 + if len(arg_string) == 1:
  2011 + return None
  2012 +
2041 2013 # if the option string before the "=" is present, return the action
2042 2014 if '=' in arg_string:
2043 2015 option_string, explicit_arg = arg_string.split('=', 1)
@@ -2176,7 +2148,7 @@ def _get_values(self, action, arg_strings):
2176 2148 value = action.const
2177 2149 else:
2178 2150 value = action.default
2179   - if isinstance(value, _basestring):
  2151 + if isinstance(value, basestring):
2180 2152 value = self._get_value(action, value)
2181 2153 self._check_value(action, value)
2182 2154
@@ -2279,6 +2251,11 @@ def format_help(self):
2279 2251 return formatter.format_help()
2280 2252
2281 2253 def format_version(self):
  2254 + import warnings
  2255 + warnings.warn(
  2256 + 'The format_version method is deprecated -- the "version" '
  2257 + 'argument to ArgumentParser is no longer supported.',
  2258 + DeprecationWarning)
2282 2259 formatter = self._get_formatter()
2283 2260 formatter.add_text(self.version)
2284 2261 return formatter.format_help()
@@ -2300,6 +2277,11 @@ def print_help(self, file=None):
2300 2277 self._print_message(self.format_help(), file)
2301 2278
2302 2279 def print_version(self, file=None):
  2280 + import warnings
  2281 + warnings.warn(
  2282 + 'The print_version method is deprecated -- the "version" '
  2283 + 'argument to ArgumentParser is no longer supported.',
  2284 + DeprecationWarning)
2303 2285 self._print_message(self.format_version(), file)
2304 2286
2305 2287 def _print_message(self, message, file=None):
4 IPython/external/configobj/__init__.py
... ... @@ -0,0 +1,4 @@
  1 +try:
  2 + from configobj import *
  3 +except ImportError:
  4 + from _configobj import *
0  IPython/external/configobj.py → IPython/external/configobj/_configobj.py
File renamed without changes
8 IPython/external/decorator/__init__.py
... ... @@ -0,0 +1,8 @@
  1 +try:
  2 + from decorator import *
  3 + from decorator import getinfo, new_wrapper
  4 + # the following funcion is deprecated so using the python own one
  5 + from functools import update_wrapper
  6 +except ImportError:
  7 + from _decorator import *
  8 + from _decorator import getinfo, update_wrapper, new_wrapper
0  IPython/external/decorator.py → IPython/external/decorator/_decorator.py
File renamed without changes
4 IPython/external/decorators/__init__.py
... ... @@ -0,0 +1,4 @@
  1 +try:
  2 + from numpy.testing.decorators import *
  3 +except ImportError:
  4 + from _decorators import *
0  IPython/external/decorators.py → IPython/external/decorators/_decorators.py
File renamed without changes
0  IPython/external/_numpy_testing_utils.py → IPython/external/decorators/_numpy_testing_utils.py
File renamed without changes
4 IPython/external/guid/__init__.py
... ... @@ -0,0 +1,4 @@
  1 +try:
  2 + from guid import *
  3 +except ImportError:
  4 + from _guid import *
0  IPython/external/guid.py → IPython/external/guid/_guid.py
File renamed without changes
4 IPython/external/mglob/__init__.py
... ... @@ -0,0 +1,4 @@
  1 +try:
  2 + from mglob import *
  3 +except ImportError:
  4 + from _mglob import *
2  IPython/external/mglob.py → IPython/external/mglob/_mglob.py 100755 → 100644
... ... @@ -1,5 +1,3 @@
1   -#!/usr/bin/env python
2   -
3 1 r""" mglob - enhanced file list expansion module
4 2
5 3 Use as stand-alone utility (for xargs, `backticks` etc.),
4 IPython/external/path/__init__.py
... ... @@ -0,0 +1,4 @@
  1 +try:
  2 + from path import *
  3 +except ImportError:
  4 + from _path import *
0  IPython/external/path.py → IPython/external/path/_path.py
File renamed without changes
5 IPython/external/pexpect/__init__.py
... ... @@ -0,0 +1,5 @@
  1 +try:
  2 + import pexpect
  3 + from pexpect import *
  4 +except ImportError:
  5 + from _pexpect import *
0  IPython/external/pexpect.py → IPython/external/pexpect/_pexpect.py
File renamed without changes
4 IPython/external/pyparsing/__init__.py
... ... @@ -0,0 +1,4 @@
  1 +try:
  2 + from pyparsing import *
  3 +except ImportError:
  4 + from _pyparsing import *
0  IPython/external/pyparsing.py → IPython/external/pyparsing/_pyparsing.py
File renamed without changes
4 IPython/external/simplegeneric/__init__.py
... ... @@ -0,0 +1,4 @@
  1 +try:
  2 + from simplegeneric import *
  3 +except ImportError:
  4 + from _simplegeneric import *
0  IPython/external/simplegeneric.py → IPython/external/simplegeneric/_simplegeneric.py
File renamed without changes
8 IPython/external/validate/__init__.py
... ... @@ -0,0 +1,8 @@
  1 +try:
  2 + import validate
  3 + if '__docformat__' in validate.__all__ and validate.__version__.split('.') >= ['1', '0', '1']:
  4 + # __docformat__ was removed in 1.0.1 but
  5 + validate.__all__ = [i for i in validate.__all__ if i != '__docformat__']
  6 + from validate import *
  7 +except ImportError:
  8 + from _validate import *
0  IPython/external/validate.py → IPython/external/validate/_validate.py
File renamed without changes
0  IPython/external/pretty.py → IPython/lib/pretty.py
File renamed without changes
11 setupbase.py
@@ -108,6 +108,17 @@ def find_packages():
108 108 add_package(packages, 'deathrow', tests=True)
109 109 add_package(packages, 'extensions')
110 110 add_package(packages, 'external')
  111 + add_package(packages, 'external.argparse')
  112 + add_package(packages, 'external.configobj')
  113 + add_package(packages, 'external.decorator')
  114 + add_package(packages, 'external.decorators')
  115 + add_package(packages, 'external.guid')
  116 + add_package(packages, 'external.Itpl')
  117 + add_package(packages, 'external.mglob')
  118 + add_package(packages, 'external.path')
  119 + add_package(packages, 'external.pyparsing')
  120 + add_package(packages, 'external.simplegeneric')
  121 + add_package(packages, 'external.validate')
111 122 add_package(packages, 'frontend')
112 123 add_package(packages, 'frontend.qt')
113 124 add_package(packages, 'frontend.qt.console', tests=True)

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.