Show More
@@ -47,7 +47,7 b' from .testing import test' | |||||
47 |
|
47 | |||
48 | # Release data |
|
48 | # Release data | |
49 | __author__ = '' |
|
49 | __author__ = '' | |
50 | for author, email in release.authors.values(): |
|
50 | for author, email in release.authors.itervalues(): | |
51 | __author__ += author + ' <' + email + '>\n' |
|
51 | __author__ += author + ' <' + email + '>\n' | |
52 | __license__ = release.license |
|
52 | __license__ = release.license | |
53 | __version__ = release.version |
|
53 | __version__ = release.version |
@@ -112,7 +112,7 b' class Configurable(HasTraits):' | |||||
112 | # dynamically create the section with name self.__class__.__name__. |
|
112 | # dynamically create the section with name self.__class__.__name__. | |
113 | if new._has_section(sname): |
|
113 | if new._has_section(sname): | |
114 | my_config = new[sname] |
|
114 | my_config = new[sname] | |
115 | for k, v in traits.items(): |
|
115 | for k, v in traits.iteritems(): | |
116 | # Don't allow traitlets with config=True to start with |
|
116 | # Don't allow traitlets with config=True to start with | |
117 | # uppercase. Otherwise, they are confused with Config |
|
117 | # uppercase. Otherwise, they are confused with Config | |
118 | # subsections. But, developers shouldn't have uppercase |
|
118 | # subsections. But, developers shouldn't have uppercase |
@@ -1,3 +1,4 b'' | |||||
|
1 | # -*- coding: utf-8 -*- | |||
1 | # coding: utf-8 |
|
2 | # coding: utf-8 | |
2 | """A simple configuration system. |
|
3 | """A simple configuration system. | |
3 |
|
4 | |||
@@ -73,7 +74,7 b' class Config(dict):' | |||||
73 |
|
74 | |||
74 | def _merge(self, other): |
|
75 | def _merge(self, other): | |
75 | to_update = {} |
|
76 | to_update = {} | |
76 | for k, v in other.items(): |
|
77 | for k, v in other.iteritems(): | |
77 | if not self.has_key(k): |
|
78 | if not self.has_key(k): | |
78 | to_update[k] = v |
|
79 | to_update[k] = v | |
79 | else: # I have this key |
|
80 | else: # I have this key | |
@@ -365,7 +366,7 b' class ArgParseConfigLoader(CommandLineConfigLoader):' | |||||
365 |
|
366 | |||
366 | def _convert_to_config(self): |
|
367 | def _convert_to_config(self): | |
367 | """self.parsed_data->self.config""" |
|
368 | """self.parsed_data->self.config""" | |
368 | for k, v in vars(self.parsed_data).items(): |
|
369 | for k, v in vars(self.parsed_data).iteritems(): | |
369 | exec_str = 'self.config.' + k + '= v' |
|
370 | exec_str = 'self.config.' + k + '= v' | |
370 | exec exec_str in locals(), globals() |
|
371 | exec exec_str in locals(), globals() | |
371 |
|
372 |
@@ -336,7 +336,7 b' def cd_completer(self, event):' | |||||
336 | return [compress_user(relpath, tilde_expand, tilde_val)] |
|
336 | return [compress_user(relpath, tilde_expand, tilde_val)] | |
337 |
|
337 | |||
338 | # if no completions so far, try bookmarks |
|
338 | # if no completions so far, try bookmarks | |
339 | bks = self.db.get('bookmarks',{}).keys() |
|
339 | bks = self.db.get('bookmarks',{}).iterkeys() | |
340 | bkmatches = [s for s in bks if s.startswith(event.symbol)] |
|
340 | bkmatches = [s for s in bks if s.startswith(event.symbol)] | |
341 | if bkmatches: |
|
341 | if bkmatches: | |
342 | return bkmatches |
|
342 | return bkmatches |
@@ -260,7 +260,7 b' class ShadowHist(object):' | |||||
260 |
|
260 | |||
261 | def all(self): |
|
261 | def all(self): | |
262 | d = self.db.hdict('shadowhist') |
|
262 | d = self.db.hdict('shadowhist') | |
263 | items = [(i,s) for (s,i) in d.items()] |
|
263 | items = [(i,s) for (s,i) in d.iteritems()] | |
264 | items.sort() |
|
264 | items.sort() | |
265 | return items |
|
265 | return items | |
266 |
|
266 |
@@ -511,7 +511,7 b' class InteractiveShell(Configurable, Magic):' | |||||
511 | def restore_sys_module_state(self): |
|
511 | def restore_sys_module_state(self): | |
512 | """Restore the state of the sys module.""" |
|
512 | """Restore the state of the sys module.""" | |
513 | try: |
|
513 | try: | |
514 | for k, v in self._orig_sys_module_state.items(): |
|
514 | for k, v in self._orig_sys_module_state.iteritems(): | |
515 | setattr(sys, k, v) |
|
515 | setattr(sys, k, v) | |
516 | except AttributeError: |
|
516 | except AttributeError: | |
517 | pass |
|
517 | pass |
@@ -356,7 +356,7 b' class InteractiveLoopTestCase(unittest.TestCase):' | |||||
356 | # We can't check that the provided ns is identical to the test_ns, |
|
356 | # We can't check that the provided ns is identical to the test_ns, | |
357 | # because Python fills test_ns with extra keys (copyright, etc). But |
|
357 | # because Python fills test_ns with extra keys (copyright, etc). But | |
358 | # we can check that the given dict is *contained* in test_ns |
|
358 | # we can check that the given dict is *contained* in test_ns | |
359 | for k,v in ns.items(): |
|
359 | for k,v in ns.iteritems(): | |
360 | self.assertEqual(test_ns[k], v) |
|
360 | self.assertEqual(test_ns[k], v) | |
361 |
|
361 | |||
362 | def test_simple(self): |
|
362 | def test_simple(self): |
@@ -33,7 +33,7 b' def test_rehashx():' | |||||
33 | # Practically ALL ipython development systems will have more than 10 aliases |
|
33 | # Practically ALL ipython development systems will have more than 10 aliases | |
34 |
|
34 | |||
35 | yield (nt.assert_true, len(_ip.alias_manager.alias_table) > 10) |
|
35 | yield (nt.assert_true, len(_ip.alias_manager.alias_table) > 10) | |
36 | for key, val in _ip.alias_manager.alias_table.items(): |
|
36 | for key, val in _ip.alias_manager.alias_table.iteritems(): | |
37 | # we must strip dots from alias names |
|
37 | # we must strip dots from alias names | |
38 | nt.assert_true('.' not in key) |
|
38 | nt.assert_true('.' not in key) | |
39 |
|
39 |
@@ -1,3 +1,4 b'' | |||||
|
1 | # -*- coding: utf-8 -*- | |||
1 | # configobj.py |
|
2 | # configobj.py | |
2 | # A config file reader/writer that supports nested sections in config files. |
|
3 | # A config file reader/writer that supports nested sections in config files. | |
3 | # Copyright (C) 2005-2008 Michael Foord, Nicola Larosa |
|
4 | # Copyright (C) 2005-2008 Michael Foord, Nicola Larosa | |
@@ -32,22 +33,7 b' except ImportError:' | |||||
32 | pass |
|
33 | pass | |
33 | from types import StringTypes |
|
34 | from types import StringTypes | |
34 | from warnings import warn |
|
35 | from warnings import warn | |
35 | try: |
|
36 | from codecs import BOM_UTF8, BOM_UTF16, BOM_UTF16_BE, BOM_UTF16_LE | |
36 | from codecs import BOM_UTF8, BOM_UTF16, BOM_UTF16_BE, BOM_UTF16_LE |
|
|||
37 | except ImportError: |
|
|||
38 | # Python 2.2 does not have these |
|
|||
39 | # UTF-8 |
|
|||
40 | BOM_UTF8 = '\xef\xbb\xbf' |
|
|||
41 | # UTF-16, little endian |
|
|||
42 | BOM_UTF16_LE = '\xff\xfe' |
|
|||
43 | # UTF-16, big endian |
|
|||
44 | BOM_UTF16_BE = '\xfe\xff' |
|
|||
45 | if sys.byteorder == 'little': |
|
|||
46 | # UTF-16, native endianness |
|
|||
47 | BOM_UTF16 = BOM_UTF16_LE |
|
|||
48 | else: |
|
|||
49 | # UTF-16, native endianness |
|
|||
50 | BOM_UTF16 = BOM_UTF16_BE |
|
|||
51 |
|
37 | |||
52 | # A dictionary mapping BOM to |
|
38 | # A dictionary mapping BOM to | |
53 | # the encoding to decode with, and what to set the |
|
39 | # the encoding to decode with, and what to set the | |
@@ -101,21 +87,6 b' wspace_plus = \' \\r\\t\\n\\v\\t\\\'"\'' | |||||
101 | tsquot = '"""%s"""' |
|
87 | tsquot = '"""%s"""' | |
102 | tdquot = "'''%s'''" |
|
88 | tdquot = "'''%s'''" | |
103 |
|
89 | |||
104 | try: |
|
|||
105 | enumerate |
|
|||
106 | except NameError: |
|
|||
107 | def enumerate(obj): |
|
|||
108 | """enumerate for Python 2.2.""" |
|
|||
109 | i = -1 |
|
|||
110 | for item in obj: |
|
|||
111 | i += 1 |
|
|||
112 | yield i, item |
|
|||
113 |
|
||||
114 | try: |
|
|||
115 | True, False |
|
|||
116 | except NameError: |
|
|||
117 | True, False = 1, 0 |
|
|||
118 |
|
||||
119 |
|
90 | |||
120 | __version__ = '4.5.2' |
|
91 | __version__ = '4.5.2' | |
121 |
|
92 | |||
@@ -814,7 +785,7 b' class Section(dict):' | |||||
814 | >>> c2 |
|
785 | >>> c2 | |
815 | {'section1': {'option1': 'False', 'subsection': {'more_options': 'False'}}} |
|
786 | {'section1': {'option1': 'False', 'subsection': {'more_options': 'False'}}} | |
816 | """ |
|
787 | """ | |
817 | for key, val in indict.items(): |
|
788 | for key, val in indict.iteritems(): | |
818 | if (key in self and isinstance(self[key], dict) and |
|
789 | if (key in self and isinstance(self[key], dict) and | |
819 | isinstance(val, dict)): |
|
790 | isinstance(val, dict)): | |
820 | self[key].merge(val) |
|
791 | self[key].merge(val) | |
@@ -1438,7 +1409,7 b' class ConfigObj(Section):' | |||||
1438 | enc = BOM_LIST[self.encoding.lower()] |
|
1409 | enc = BOM_LIST[self.encoding.lower()] | |
1439 | if enc == 'utf_16': |
|
1410 | if enc == 'utf_16': | |
1440 | # For UTF16 we try big endian and little endian |
|
1411 | # For UTF16 we try big endian and little endian | |
1441 | for BOM, (encoding, final_encoding) in BOMS.items(): |
|
1412 | for BOM, (encoding, final_encoding) in BOMS.iteritems(): | |
1442 | if not final_encoding: |
|
1413 | if not final_encoding: | |
1443 | # skip UTF8 |
|
1414 | # skip UTF8 | |
1444 | continue |
|
1415 | continue | |
@@ -1468,7 +1439,7 b' class ConfigObj(Section):' | |||||
1468 | return self._decode(infile, self.encoding) |
|
1439 | return self._decode(infile, self.encoding) | |
1469 |
|
1440 | |||
1470 | # No encoding specified - so we need to check for UTF8/UTF16 |
|
1441 | # No encoding specified - so we need to check for UTF8/UTF16 | |
1471 | for BOM, (encoding, final_encoding) in BOMS.items(): |
|
1442 | for BOM, (encoding, final_encoding) in BOMS.iteritems(): | |
1472 | if not line.startswith(BOM): |
|
1443 | if not line.startswith(BOM): | |
1473 | continue |
|
1444 | continue | |
1474 | else: |
|
1445 | else: | |
@@ -2481,7 +2452,7 b' def flatten_errors(cfg, res, levels=None, results=None):' | |||||
2481 | if levels: |
|
2452 | if levels: | |
2482 | levels.pop() |
|
2453 | levels.pop() | |
2483 | return results |
|
2454 | return results | |
2484 | for (key, val) in res.items(): |
|
2455 | for (key, val) in res.iteritems(): | |
2485 | if val == True: |
|
2456 | if val == True: | |
2486 | continue |
|
2457 | continue | |
2487 | if isinstance(cfg.get(key), dict): |
|
2458 | if isinstance(cfg.get(key), dict): |
@@ -138,9 +138,6 b" def pprint(obj, verbose=False, max_width=79, newline='\\n'):" | |||||
138 | sys.stdout.write(newline) |
|
138 | sys.stdout.write(newline) | |
139 | sys.stdout.flush() |
|
139 | sys.stdout.flush() | |
140 |
|
140 | |||
141 |
|
||||
142 | # add python2.5 context managers if we have the with statement feature |
|
|||
143 | if hasattr(__future__, 'with_statement'): exec ''' |
|
|||
144 | from __future__ import with_statement |
|
141 | from __future__ import with_statement | |
145 | from contextlib import contextmanager |
|
142 | from contextlib import contextmanager | |
146 |
|
143 | |||
@@ -164,16 +161,6 b' class _PrettyPrinterBase(object):' | |||||
164 | yield |
|
161 | yield | |
165 | finally: |
|
162 | finally: | |
166 | self.end_group(indent, close) |
|
163 | self.end_group(indent, close) | |
167 | ''' |
|
|||
168 | else: |
|
|||
169 | class _PrettyPrinterBase(object): |
|
|||
170 |
|
||||
171 | def _unsupported(self, *a, **kw): |
|
|||
172 | """unsupported operation""" |
|
|||
173 | raise RuntimeError('not available in this python version') |
|
|||
174 | group = indent = _unsupported |
|
|||
175 | del _unsupported |
|
|||
176 |
|
||||
177 |
|
164 | |||
178 | class PrettyPrinter(_PrettyPrinterBase): |
|
165 | class PrettyPrinter(_PrettyPrinterBase): | |
179 | """ |
|
166 | """ |
@@ -1,3 +1,4 b'' | |||||
|
1 | # -*- coding: utf-8 -*- | |||
1 | # module pyparsing.py |
|
2 | # module pyparsing.py | |
2 | # |
|
3 | # | |
3 | # Copyright (c) 2003-2009 Paul T. McGuire |
|
4 | # Copyright (c) 2003-2009 Paul T. McGuire | |
@@ -400,7 +401,7 b' class ParseResults(object):' | |||||
400 |
|
401 | |||
401 | def values( self ): |
|
402 | def values( self ): | |
402 | """Returns all named result values.""" |
|
403 | """Returns all named result values.""" | |
403 | return [ v[-1][0] for v in self.__tokdict.values() ] |
|
404 | return [ v[-1][0] for v in self.__tokdict.itervalues() ] | |
404 |
|
405 | |||
405 | def __getattr__( self, name ): |
|
406 | def __getattr__( self, name ): | |
406 | if name not in self.__slots__: |
|
407 | if name not in self.__slots__: | |
@@ -422,7 +423,7 b' class ParseResults(object):' | |||||
422 | if other.__tokdict: |
|
423 | if other.__tokdict: | |
423 | offset = len(self.__toklist) |
|
424 | offset = len(self.__toklist) | |
424 | addoffset = ( lambda a: (a<0 and offset) or (a+offset) ) |
|
425 | addoffset = ( lambda a: (a<0 and offset) or (a+offset) ) | |
425 | otheritems = other.__tokdict.items() |
|
426 | otheritems = other.__tokdict.iteritems() | |
426 | otherdictitems = [(k, _ParseResultsWithOffset(v[0],addoffset(v[1])) ) |
|
427 | otherdictitems = [(k, _ParseResultsWithOffset(v[0],addoffset(v[1])) ) | |
427 | for (k,vlist) in otheritems for v in vlist] |
|
428 | for (k,vlist) in otheritems for v in vlist] | |
428 | for k,v in otherdictitems: |
|
429 | for k,v in otherdictitems: | |
@@ -488,7 +489,7 b' class ParseResults(object):' | |||||
488 | """Returns the parse results as XML. Tags are created for tokens and lists that have defined results names.""" |
|
489 | """Returns the parse results as XML. Tags are created for tokens and lists that have defined results names.""" | |
489 | nl = "\n" |
|
490 | nl = "\n" | |
490 | out = [] |
|
491 | out = [] | |
491 |
namedItems = dict( |
|
492 | namedItems = dict([(v[1],k) for (k,vlist) in self.__tokdict.iteritems() | |
492 | for v in vlist ] ) |
|
493 | for v in vlist ] ) | |
493 | nextLevelIndent = indent + " " |
|
494 | nextLevelIndent = indent + " " | |
494 |
|
495 | |||
@@ -545,7 +546,7 b' class ParseResults(object):' | |||||
545 | return "".join(out) |
|
546 | return "".join(out) | |
546 |
|
547 | |||
547 | def __lookup(self,sub): |
|
548 | def __lookup(self,sub): | |
548 | for k,vlist in self.__tokdict.items(): |
|
549 | for k,vlist in self.__tokdict.iteritems(): | |
549 | for v,loc in vlist: |
|
550 | for v,loc in vlist: | |
550 | if sub is v: |
|
551 | if sub is v: | |
551 | return k |
|
552 | return k | |
@@ -2563,7 +2564,7 b' class Each(ParseExpression):' | |||||
2563 | tmp += ParseResults(r[k]) |
|
2564 | tmp += ParseResults(r[k]) | |
2564 | dups[k] = tmp |
|
2565 | dups[k] = tmp | |
2565 | finalResults += ParseResults(r) |
|
2566 | finalResults += ParseResults(r) | |
2566 | for k,v in dups.items(): |
|
2567 | for k,v in dups.iteritems(): | |
2567 | finalResults[k] = v |
|
2568 | finalResults[k] = v | |
2568 | return loc, finalResults |
|
2569 | return loc, finalResults | |
2569 |
|
2570 | |||
@@ -3442,7 +3443,7 b' def withAttribute(*args,**attrDict):' | |||||
3442 | if args: |
|
3443 | if args: | |
3443 | attrs = args[:] |
|
3444 | attrs = args[:] | |
3444 | else: |
|
3445 | else: | |
3445 | attrs = attrDict.items() |
|
3446 | attrs = attrDict.iteritems() | |
3446 | attrs = [(k,v) for k,v in attrs] |
|
3447 | attrs = [(k,v) for k,v in attrs] | |
3447 | def pa(s,l,tokens): |
|
3448 | def pa(s,l,tokens): | |
3448 | for attrName,attrValue in attrs: |
|
3449 | for attrName,attrValue in attrs: |
@@ -617,7 +617,7 b' class WindowsHPCLauncher(BaseLauncher):' | |||||
617 | # Twisted will raise DeprecationWarnings if we try to pass unicode to this |
|
617 | # Twisted will raise DeprecationWarnings if we try to pass unicode to this | |
618 | output = yield getProcessOutput(str(self.job_cmd), |
|
618 | output = yield getProcessOutput(str(self.job_cmd), | |
619 | [str(a) for a in args], |
|
619 | [str(a) for a in args], | |
620 | env=dict((str(k),str(v)) for k,v in os.environ.items()), |
|
620 | env=dict((str(k),str(v)) for k,v in os.environ.iteritems()), | |
621 | path=self.work_dir |
|
621 | path=self.work_dir | |
622 | ) |
|
622 | ) | |
623 | except: |
|
623 | except: |
@@ -59,7 +59,7 b' class PendingDeferredManagerTest(DeferredTestCase):' | |||||
59 | did = self.pdm.save_pending_deferred(d) |
|
59 | did = self.pdm.save_pending_deferred(d) | |
60 | dDict[did] = d |
|
60 | dDict[did] = d | |
61 | # Make sure they are begin saved |
|
61 | # Make sure they are begin saved | |
62 | for k in dDict.keys(): |
|
62 | for k in dDict.iterkeys(): | |
63 | self.assert_(self.pdm.quick_has_id(k)) |
|
63 | self.assert_(self.pdm.quick_has_id(k)) | |
64 | # Get the pending deferred (block=True), then callback with 'foo' and compare |
|
64 | # Get the pending deferred (block=True), then callback with 'foo' and compare | |
65 | for did in dDict.keys()[0:5]: |
|
65 | for did in dDict.keys()[0:5]: |
@@ -212,7 +212,7 b' class WinHPCTask(Configurable):' | |||||
212 |
|
212 | |||
213 | def get_env_vars(self): |
|
213 | def get_env_vars(self): | |
214 | env_vars = ET.Element('EnvironmentVariables') |
|
214 | env_vars = ET.Element('EnvironmentVariables') | |
215 | for k, v in self.environment_variables.items(): |
|
215 | for k, v in self.environment_variables.iteritems(): | |
216 | variable = ET.SubElement(env_vars, "Variable") |
|
216 | variable = ET.SubElement(env_vars, "Variable") | |
217 | name = ET.SubElement(variable, "Name") |
|
217 | name = ET.SubElement(variable, "Name") | |
218 | name.text = k |
|
218 | name.text = k |
General Comments 0
You need to be logged in to leave comments.
Login now