Python __future__.all_feature_names() Examples
The following are 30
code examples of __future__.all_feature_names().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
__future__
, or try the search function
.
Example #1
Source File: _util.py From myhdl with GNU Lesser General Public License v2.1 | 6 votes |
def _makeAST(f): # Need to look at the flags used to compile the original function f and # pass these same flags to the compile() function. This ensures that # syntax-changing __future__ imports like print_function work correctly. orig_f_co_flags = f.__code__.co_flags # co_flags can contain various internal flags that we can't pass to # compile(), so strip them out here valid_flags = 0 for future_feature in __future__.all_feature_names: feature = getattr(__future__, future_feature) valid_flags |= feature.compiler_flag s = inspect.getsource(f) s = _dedent(s) # use compile instead of ast.parse so that additional flags can be passed flags = ast.PyCF_ONLY_AST | (orig_f_co_flags & valid_flags) tree = compile(s, filename='<unknown>', mode='exec', flags=flags, dont_inherit=True) # tree = ast.parse(s) tree.sourcefile = inspect.getsourcefile(f) tree.lineoffset = inspect.getsourcelines(f)[1] - 1 return tree
Example #2
Source File: doctest.py From RevitBatchProcessor with GNU General Public License v3.0 | 5 votes |
def _extract_future_flags(globs): """ Return the compiler-flags associated with the future features that have been imported into the given namespace (globs). """ flags = 0 for fname in __future__.all_feature_names: feature = globs.get(fname, None) if feature is getattr(__future__, fname): flags |= feature.compiler_flag return flags
Example #3
Source File: test___future__.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_names(self): # Verify that all_feature_names appears correct. given_feature_names = features[:] for name in dir(__future__): obj = getattr(__future__, name, None) if obj is not None and isinstance(obj, __future__._Feature): self.assertTrue( name in given_feature_names, "%r should have been in all_feature_names" % name ) given_feature_names.remove(name) self.assertEqual(len(given_feature_names), 0, "all_feature_names has too much: %r" % given_feature_names)
Example #4
Source File: eval.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _all_future_flags(): flags = 0 for feature_name in __future__.all_feature_names: feature = getattr(__future__, feature_name) if feature.getMandatoryRelease() > sys.version_info: flags |= feature.compiler_flag return flags
Example #5
Source File: doctest.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _extract_future_flags(globs): """ Return the compiler-flags associated with the future features that have been imported into the given namespace (globs). """ flags = 0 for fname in __future__.all_feature_names: feature = globs.get(fname, None) if feature is getattr(__future__, fname): flags |= feature.compiler_flag return flags
Example #6
Source File: doctest.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def _extract_future_flags(globs): """ Return the compiler-flags associated with the future features that have been imported into the given namespace (globs). """ flags = 0 for fname in __future__.all_feature_names: feature = globs.get(fname, None) if feature is getattr(__future__, fname): flags |= feature.compiler_flag return flags
Example #7
Source File: test___future__.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_names(self): # Verify that all_feature_names appears correct. given_feature_names = features[:] for name in dir(__future__): obj = getattr(__future__, name, None) if obj is not None and isinstance(obj, __future__._Feature): self.assertTrue( name in given_feature_names, "%r should have been in all_feature_names" % name ) given_feature_names.remove(name) self.assertEqual(len(given_feature_names), 0, "all_feature_names has too much: %r" % given_feature_names)
Example #8
Source File: doctest.py From medicare-demo with Apache License 2.0 | 5 votes |
def _extract_future_flags(globs): """ Return the compiler-flags associated with the future features that have been imported into the given namespace (globs). """ flags = 0 for fname in __future__.all_feature_names: feature = globs.get(fname, None) if feature is getattr(__future__, fname): flags |= feature.compiler_flag return flags
Example #9
Source File: doctest.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def _extract_future_flags(globs): """ Return the compiler-flags associated with the future features that have been imported into the given namespace (globs). """ flags = 0 for fname in __future__.all_feature_names: feature = globs.get(fname, None) if feature is getattr(__future__, fname): flags |= feature.compiler_flag return flags
Example #10
Source File: doctest.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def _extract_future_flags(globs): """ Return the compiler-flags associated with the future features that have been imported into the given namespace (globs). """ flags = 0 for fname in __future__.all_feature_names: feature = globs.get(fname, None) if feature is getattr(__future__, fname): flags |= feature.compiler_flag return flags
Example #11
Source File: test___future__.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_names(self): # Verify that all_feature_names appears correct. given_feature_names = features[:] for name in dir(__future__): obj = getattr(__future__, name, None) if obj is not None and isinstance(obj, __future__._Feature): self.assertTrue( name in given_feature_names, "%r should have been in all_feature_names" % name ) given_feature_names.remove(name) self.assertEqual(len(given_feature_names), 0, "all_feature_names has too much: %r" % given_feature_names)
Example #12
Source File: _doctest.py From luscan-devel with GNU General Public License v2.0 | 5 votes |
def _extract_future_flags(globs): """ Return the compiler-flags associated with the future features that have been imported into the given namespace (globs). """ flags = 0 for fname in __future__.all_feature_names: feature = globs.get(fname, None) if feature is getattr(__future__, fname): flags |= feature.compiler_flag return flags
Example #13
Source File: doctest.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def _extract_future_flags(globs): """ Return the compiler-flags associated with the future features that have been imported into the given namespace (globs). """ flags = 0 for fname in __future__.all_feature_names: feature = globs.get(fname, None) if feature is getattr(__future__, fname): flags |= feature.compiler_flag return flags
Example #14
Source File: doctest.py From unity-python with MIT License | 5 votes |
def _extract_future_flags(globs): """ Return the compiler-flags associated with the future features that have been imported into the given namespace (globs). """ flags = 0 for fname in __future__.all_feature_names: feature = globs.get(fname, None) if feature is getattr(__future__, fname): flags |= feature.compiler_flag return flags
Example #15
Source File: doctest.py From android_universal with MIT License | 5 votes |
def _extract_future_flags(globs): """ Return the compiler-flags associated with the future features that have been imported into the given namespace (globs). """ flags = 0 for fname in __future__.all_feature_names: feature = globs.get(fname, None) if feature is getattr(__future__, fname): flags |= feature.compiler_flag return flags
Example #16
Source File: test___future__.py From android_universal with MIT License | 5 votes |
def test_names(self): # Verify that all_feature_names appears correct. given_feature_names = features[:] for name in dir(__future__): obj = getattr(__future__, name, None) if obj is not None and isinstance(obj, __future__._Feature): self.assertTrue( name in given_feature_names, "%r should have been in all_feature_names" % name ) given_feature_names.remove(name) self.assertEqual(len(given_feature_names), 0, "all_feature_names has too much: %r" % given_feature_names)
Example #17
Source File: doctest.py From canape with GNU General Public License v3.0 | 5 votes |
def _extract_future_flags(globs): """ Return the compiler-flags associated with the future features that have been imported into the given namespace (globs). """ flags = 0 for fname in __future__.all_feature_names: feature = globs.get(fname, None) if feature is getattr(__future__, fname): flags |= feature.compiler_flag return flags
Example #18
Source File: doctest.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def _extract_future_flags(globs): """ Return the compiler-flags associated with the future features that have been imported into the given namespace (globs). """ flags = 0 for fname in __future__.all_feature_names: feature = globs.get(fname, None) if feature is getattr(__future__, fname): flags |= feature.compiler_flag return flags
Example #19
Source File: doctest.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def _extract_future_flags(globs): """ Return the compiler-flags associated with the future features that have been imported into the given namespace (globs). """ flags = 0 for fname in __future__.all_feature_names: feature = globs.get(fname, None) if feature is getattr(__future__, fname): flags |= feature.compiler_flag return flags
Example #20
Source File: test___future__.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_names(self): # Verify that all_feature_names appears correct. given_feature_names = features[:] for name in dir(__future__): obj = getattr(__future__, name, None) if obj is not None and isinstance(obj, __future__._Feature): self.assertTrue( name in given_feature_names, "%r should have been in all_feature_names" % name ) given_feature_names.remove(name) self.assertEqual(len(given_feature_names), 0, "all_feature_names has too much: %r" % given_feature_names)
Example #21
Source File: doctest.py From Flask with Apache License 2.0 | 5 votes |
def _extract_future_flags(globs): """ Return the compiler-flags associated with the future features that have been imported into the given namespace (globs). """ flags = 0 for fname in __future__.all_feature_names: feature = globs.get(fname, None) if feature is getattr(__future__, fname): flags |= feature.compiler_flag return flags
Example #22
Source File: doctest.py From Flask with Apache License 2.0 | 5 votes |
def _extract_future_flags(globs): """ Return the compiler-flags associated with the future features that have been imported into the given namespace (globs). """ flags = 0 for fname in __future__.all_feature_names: feature = globs.get(fname, None) if feature is getattr(__future__, fname): flags |= feature.compiler_flag return flags
Example #23
Source File: test___future__.py From BinderFilter with MIT License | 5 votes |
def test_names(self): # Verify that all_feature_names appears correct. given_feature_names = features[:] for name in dir(__future__): obj = getattr(__future__, name, None) if obj is not None and isinstance(obj, __future__._Feature): self.assertTrue( name in given_feature_names, "%r should have been in all_feature_names" % name ) given_feature_names.remove(name) self.assertEqual(len(given_feature_names), 0, "all_feature_names has too much: %r" % given_feature_names)
Example #24
Source File: checker.py From linter-pylama with MIT License | 5 votes |
def IMPORTFROM(self, node): if node.module == '__future__': if not self.futuresAllowed: self.report(messages.LateFutureImport, node, [n.name for n in node.names]) else: self.futuresAllowed = False module = ('.' * node.level) + (node.module or '') for alias in node.names: name = alias.asname or alias.name if node.module == '__future__': importation = FutureImportation(name, node, self.scope) if alias.name not in __future__.all_feature_names: self.report(messages.FutureFeatureNotDefined, node, alias.name) elif alias.name == '*': # Only Python 2, local import * is a SyntaxWarning if not PY2 and not isinstance(self.scope, ModuleScope): self.report(messages.ImportStarNotPermitted, node, module) continue self.scope.importStarred = True self.report(messages.ImportStarUsed, node, module) importation = StarImportation(module, node) else: importation = ImportationFrom(name, node, module, alias.name) self.addBinding(node, importation)
Example #25
Source File: eval.py From plydata with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _all_future_flags(): flags = 0 for feature_name in __future__.all_feature_names: feature = getattr(__future__, feature_name) if feature.getMandatoryRelease() > sys.version_info: flags |= feature.compiler_flag return flags
Example #26
Source File: doctest24.py From mishkal with GNU General Public License v3.0 | 5 votes |
def _extract_future_flags(globs): """ Return the compiler-flags associated with the future features that have been imported into the given namespace (globs). """ flags = 0 for fname in __future__.all_feature_names: feature = globs.get(fname, None) if feature is getattr(__future__, fname): flags |= feature.compiler_flag return flags
Example #27
Source File: doctest.py From meddle with MIT License | 5 votes |
def _extract_future_flags(globs): """ Return the compiler-flags associated with the future features that have been imported into the given namespace (globs). """ flags = 0 for fname in __future__.all_feature_names: feature = globs.get(fname, None) if feature is getattr(__future__, fname): flags |= feature.compiler_flag return flags
Example #28
Source File: doctest.py From pledgeservice with Apache License 2.0 | 5 votes |
def _extract_future_flags(globs): """ Return the compiler-flags associated with the future features that have been imported into the given namespace (globs). """ flags = 0 for fname in __future__.all_feature_names: feature = globs.get(fname, None) if feature is getattr(__future__, fname): flags |= feature.compiler_flag return flags
Example #29
Source File: doctest.py From ironpython2 with Apache License 2.0 | 5 votes |
def _extract_future_flags(globs): """ Return the compiler-flags associated with the future features that have been imported into the given namespace (globs). """ flags = 0 for fname in __future__.all_feature_names: feature = globs.get(fname, None) if feature is getattr(__future__, fname): flags |= feature.compiler_flag return flags
Example #30
Source File: test___future__.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_names(self): # Verify that all_feature_names appears correct. given_feature_names = features[:] for name in dir(__future__): obj = getattr(__future__, name, None) if obj is not None and isinstance(obj, __future__._Feature): self.assertTrue( name in given_feature_names, "%r should have been in all_feature_names" % name ) given_feature_names.remove(name) self.assertEqual(len(given_feature_names), 0, "all_feature_names has too much: %r" % given_feature_names)