summaryrefslogtreecommitdiffstats
path: root/Python/Dependencies/future-0.18.2/src/libpasteurize/fixes/fix_features.py
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2022-12-17 17:26:16 -0800
committeryum <yum.food.vr@gmail.com>2022-12-17 17:26:16 -0800
commit4d836989720523cd0363927e3e066f56b9dc445c (patch)
treef7a9ff7cb50eda1ff29e91c78067dcc5e0ce6233 /Python/Dependencies/future-0.18.2/src/libpasteurize/fixes/fix_features.py
parentda754e9cf5b192239826aa1619e1ada3c98daa45 (diff)
Check in `future` package
I hit some issues installing Whisper and had to embed this package. I haven't taken the time to deeply understand what's going on. I think that embedded Python follows different rules about resolving module paths than regular system Python. Basically, `future`'s setup.py has a line like `import src`, where `src` is a module inside future (like `future/src/__init__.py`). This doesn't work unless we put that directory on the search path.
Diffstat (limited to 'Python/Dependencies/future-0.18.2/src/libpasteurize/fixes/fix_features.py')
-rw-r--r--Python/Dependencies/future-0.18.2/src/libpasteurize/fixes/fix_features.py86
1 files changed, 86 insertions, 0 deletions
diff --git a/Python/Dependencies/future-0.18.2/src/libpasteurize/fixes/fix_features.py b/Python/Dependencies/future-0.18.2/src/libpasteurize/fixes/fix_features.py
new file mode 100644
index 0000000..52630f9
--- /dev/null
+++ b/Python/Dependencies/future-0.18.2/src/libpasteurize/fixes/fix_features.py
@@ -0,0 +1,86 @@
+u"""
+Warn about features that are not present in Python 2.5, giving a message that
+points to the earliest version of Python 2.x (or 3.x, if none) that supports it
+"""
+
+from .feature_base import Feature, Features
+from lib2to3 import fixer_base
+
+FEATURES = [
+ #(FeatureName,
+ # FeaturePattern,
+ # FeatureMinVersion,
+ #),
+ (u"memoryview",
+ u"power < 'memoryview' trailer < '(' any* ')' > any* >",
+ u"2.7",
+ ),
+ (u"numbers",
+ u"""import_from< 'from' 'numbers' 'import' any* > |
+ import_name< 'import' ('numbers' dotted_as_names< any* 'numbers' any* >) >""",
+ u"2.6",
+ ),
+ (u"abc",
+ u"""import_name< 'import' ('abc' dotted_as_names< any* 'abc' any* >) > |
+ import_from< 'from' 'abc' 'import' any* >""",
+ u"2.6",
+ ),
+ (u"io",
+ u"""import_name< 'import' ('io' dotted_as_names< any* 'io' any* >) > |
+ import_from< 'from' 'io' 'import' any* >""",
+ u"2.6",
+ ),
+ (u"bin",
+ u"power< 'bin' trailer< '(' any* ')' > any* >",
+ u"2.6",
+ ),
+ (u"formatting",
+ u"power< any trailer< '.' 'format' > trailer< '(' any* ')' > >",
+ u"2.6",
+ ),
+ (u"nonlocal",
+ u"global_stmt< 'nonlocal' any* >",
+ u"3.0",
+ ),
+ (u"with_traceback",
+ u"trailer< '.' 'with_traceback' >",
+ u"3.0",
+ ),
+]
+
+class FixFeatures(fixer_base.BaseFix):
+
+ run_order = 9 # Wait until all other fixers have run to check for these
+
+ # To avoid spamming, we only want to warn for each feature once.
+ features_warned = set()
+
+ # Build features from the list above
+ features = Features([Feature(name, pattern, version) for \
+ name, pattern, version in FEATURES])
+
+ PATTERN = features.PATTERN
+
+ def match(self, node):
+ to_ret = super(FixFeatures, self).match(node)
+ # We want the mapping only to tell us the node's specific information.
+ try:
+ del to_ret[u'node']
+ except Exception:
+ # We want it to delete the 'node' from the results
+ # if it's there, so we don't care if it fails for normal reasons.
+ pass
+ return to_ret
+
+ def transform(self, node, results):
+ for feature_name in results:
+ if feature_name in self.features_warned:
+ continue
+ else:
+ curr_feature = self.features[feature_name]
+ if curr_feature.version >= u"3":
+ fail = self.cannot_convert
+ else:
+ fail = self.warning
+ fail(node, reason=curr_feature.message_text())
+ self.features_warned.add(feature_name)