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