Skip to content

Commit

Permalink
2to3:
Browse files Browse the repository at this point in the history
* drop libpasteurize.fixes.fix_division
* replace lib2to3.fixes.fix_import with libfuturize.fixes.fix_absolute_import (with PyQt exclude plus AlgorithmsTestBase)
* drop lib2to3.fixes.fix_print (replaced with libfuturize.fixes.fix_print_with_import)
  • Loading branch information
jef-n committed Mar 23, 2016
1 parent f197b7c commit 45c9ea2
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 24 deletions.
40 changes: 30 additions & 10 deletions scripts/addfix.pl
Expand Up @@ -2,7 +2,7 @@
use strict;
use warnings;

for my $fix (qw/
my @fixes = qw/
lib2to3.fixes.fix_apply
lib2to3.fixes.fix_basestring
lib2to3.fixes.fix_dict
Expand Down Expand Up @@ -40,7 +40,6 @@
lib2to3.fixes.fix_xreadlines
lib2to3.fixes.fix_zip
libfuturize.fixes.fix_absolute_import
libfuturize.fixes.fix_cmp
libfuturize.fixes.fix_execfile
libfuturize.fixes.fix_future_builtins
Expand All @@ -52,12 +51,16 @@
libfuturize.fixes.fix_print_with_import
libfuturize.fixes.fix_raise
libfuturize.fixes.fix_xrange_with_import
libpasteurize.fixes.fix_division
libpasteurize.fixes.fix_newstyle
/) {
/;

my %files;
for my $filename (glob "scripts/qgis_fixes/fix_*.py") {
$files{$filename}=1;
}

for my $fix (@fixes) {
my($f) = $fix =~ /\.(fix_.*)$/;
next if -f "scripts/qgis_fixes/$f.py";

my $p = $fix;
$p =~ s#\.#/#g;
Expand All @@ -69,8 +72,25 @@
}
close F;

print "$p.py => scripts/qgis_fixes/$f.py\n";
open F, ">scripts/qgis_fixes/$f.py";
print F "from $fix import $c\n";
close F;
my $filename = "scripts/qgis_fixes/$f.py";
my $content = "from $fix import $c\n";
delete $files{$filename};

#print "CHECK $filename: $content";

if(-f $filename) {
open F, $filename;
my $f = <F>;
close F;

print "WRONG $filename:\n FOUND:$f EXPECTED:$f" if $f ne $content;
} else {
print "WRITE $filename: $content";

open F, ">$filename";
print F $content;
close F;
}
}

print "LOCAL FIXES:\n ", join( "\n ", keys %files), "\n";
11 changes: 10 additions & 1 deletion scripts/qgis_fixes/fix_absolute_import.py
@@ -1 +1,10 @@
from libfuturize.fixes.fix_absolute_import import FixAbsoluteImport
from libfuturize.fixes.fix_absolute_import import FixAbsoluteImport as FixAbsoluteImportOrig

class FixAbsoluteImport(FixAbsoluteImportOrig):

def probably_a_local_import(self, imp_name):
if imp_name.startswith(u"PyQt"):
return False
if imp_name == "AlgorithmsTestBase":
return False
return super(FixAbsoluteImport, self).probably_a_local_import(imp_name)
1 change: 0 additions & 1 deletion scripts/qgis_fixes/fix_division.py

This file was deleted.

9 changes: 0 additions & 9 deletions scripts/qgis_fixes/fix_import.py

This file was deleted.

1 change: 0 additions & 1 deletion scripts/qgis_fixes/fix_print.py

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/qgis_fixes/fix_pyqt.py
Expand Up @@ -374,7 +374,7 @@

def build_pattern():
bare = set()
for old_module, changes in MAPPING.items():
for old_module, changes in list(MAPPING.items()):
for change in changes:
new_module, members = change
members = alternates(members)
Expand Down
2 changes: 1 addition & 1 deletion scripts/qgis_fixes/fix_uiimport.py
Expand Up @@ -32,7 +32,7 @@ def transform(self, node, results):
else:
first = imp
if isinstance(imp, Node):
first = imp.leaves().next()
first = next(imp.leaves())

if not isinstance(first, Leaf):
return
Expand Down

0 comments on commit 45c9ea2

Please sign in to comment.