electron/build/js_wrap.py
Matheus Rocha Vieira 1249c6ebf4 fix: Comparison using is when operands support __eq__ (#17864)
* Comparison using is when operands support __eq__

Comparison using 'is' when equivalence is not the same as identity

When you compare two values using the is or is not operator, it is the object identities of the two values that is tested rather than their equality. If the class of either of the values in the comparison redefines equality then the is operator may return False even though the objects compare as equal. Equality is defined by the __eq__ or, in Python2, __cmp__ method. To compare two objects for equality, use the == or != operator instead.

Recommendation
When you want to compare the value of two literals, use the comparison operator == or != in place of is or is not.

If the uniqueness property or performance are important then use an object that does not redefine equality.

* fix: Comparison using is when operands support __eq__

Comparison using 'is' when equivalence is not the same as identity

When you compare two values using the is or is not operator, it is the object identities of the two values that is tested rather than their equality. If the class of either of the values in the comparison redefines equality then the is operator may return False even though the objects compare as equal. Equality is defined by the __eq__ or, in Python2, __cmp__ method. To compare two objects for equality, use the == or != operator instead.

Recommendation
When you want to compare the value of two literals, use the comparison operator == or != in place of is or is not.

If the uniqueness property or performance are important then use an object that does not redefine equality.
2019-04-19 12:24:41 -07:00

19 lines
577 B
Python

import sys
in_start = sys.argv.index("--in") + 1
out_start = sys.argv.index("--out") + 1
in_bundles = sys.argv[in_start:out_start - 1]
out_bundles = sys.argv[out_start:]
if len(in_bundles) != len(out_bundles):
print("--out and --in must provide the same number of arguments")
sys.exit(1)
for i in range(len(in_bundles)):
in_bundle = in_bundles[i]
out_path = out_bundles[i]
with open(in_bundle, 'r') as f:
lines = ["(function(){var exports={},module={exports};"] + f.readlines() + ["})();"]
with open(out_path, 'w') as out_f:
out_f.writelines(lines)