[MediaWiki-commits] [Gerrit] zhtable makefile: Remove unused variables, fix almost all pe... - change (mediawiki/core)

2015-10-17 Thread Liangent (Code Review)
Liangent has submitted this change and it was merged.

Change subject: zhtable makefile: Remove unused variables, fix almost all pep8 
errors
..


zhtable makefile: Remove unused variables, fix almost all pep8 errors

Change-Id: I7ab1ffeeb2a5592fbe143f27801c11248c167093
---
M maintenance/language/zhtable/Makefile.py
1 file changed, 235 insertions(+), 207 deletions(-)

Approvals:
  Hashar: Looks good to me, but someone else must approve
  Liangent: Looks good to me, approved



diff --git a/maintenance/language/zhtable/Makefile.py 
b/maintenance/language/zhtable/Makefile.py
index 4ab57d4..5924c66 100755
--- a/maintenance/language/zhtable/Makefile.py
+++ b/maintenance/language/zhtable/Makefile.py
@@ -1,9 +1,13 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 # @author Philip
-import tarfile as tf
-import zipfile as zf
-import os, re, shutil, sys, platform
+import os
+import platform
+import re
+import shutil
+import sys
+import tarfile
+import zipfile
 
 pyversion = platform.python_version()
 islinux = platform.system().lower() == 'linux'
@@ -18,16 +22,18 @@
 if i < 0x1:
 return _unichr(i)
 else:
-return _unichr( 0xD7C0 + ( i>>10 ) ) + _unichr( 0xDC00 + ( i & 
0x3FF ) )
+return _unichr(0xD7C0 + (i >> 10)) + _unichr(0xDC00 + (i & 
0x3FF))
 elif pyversion[:2] == '3.':
 import urllib.request as urllib_request
 unichr = chr
 
-def unichr2( *args ):
-return [unichr( int( i.split('<')[0][2:], 16 ) ) for i in args]
 
-def unichr3( *args ):
-return [unichr( int( i[2:7], 16 ) ) for i in args if i[2:7]]
+def unichr2(*args):
+return [unichr(int(i.split('<')[0][2:], 16)) for i in args]
+
+
+def unichr3(*args):
+return [unichr(int(i[2:7], 16)) for i in args if i[2:7]]
 
 # DEFINE
 UNIHAN_VER = '6.3.0'
@@ -37,189 +43,201 @@
 LIBTABE_VER = '0.2.3'
 # END OF DEFINE
 
-def download( url, dest ):
-if os.path.isfile( dest ):
-print( 'File %s is up to date.' % dest )
+
+def download(url, dest):
+if os.path.isfile(dest):
+print('File %s is up to date.' % dest)
 return
 global islinux
 if islinux:
-# we use wget instead urlretrieve under Linux, 
+# we use wget instead urlretrieve under Linux,
 # because wget could display details like download progress
-os.system( 'wget %s -O %s' % ( url, dest ) )
+os.system('wget %s -O %s' % (url, dest))
 else:
-print( 'Downloading from [%s] ...' % url )
-urllib_request.urlretrieve( url, dest )
-print( 'Download complete.\n' )
+print('Downloading from [%s] ...' % url)
+urllib_request.urlretrieve(url, dest)
+print('Download complete.\n')
 return
 
-def uncompress( fp, member, encoding = 'U8' ):
-name = member.rsplit( '/', 1 )[-1]
-print( 'Extracting %s ...' % name )
-fp.extract( member )
-shutil.move( member, name )
+
+def uncompress(fp, member, encoding='U8'):
+name = member.rsplit('/', 1)[-1]
+print('Extracting %s ...' % name)
+fp.extract(member)
+shutil.move(member, name)
 if '/' in member:
-shutil.rmtree( member.split( '/', 1 )[0] )
+shutil.rmtree(member.split('/', 1)[0])
 if pyversion[:1] in ['2']:
-fc = open( name, 'rb', encoding, 'ignore' )
+fc = open(name, 'rb', encoding, 'ignore')
 else:
-fc = open( name, 'r', encoding = encoding, errors = 'ignore' )
+fc = open(name, 'r', encoding=encoding, errors='ignore')
 return fc
 
 unzip = lambda path, member, encoding = 'U8': \
-uncompress( zf.ZipFile( path ), member, encoding )
+uncompress(zipfile.ZipFile(path), member, encoding)
 
 untargz = lambda path, member, encoding = 'U8': \
-uncompress( tf.open( path, 'r:gz' ), member, encoding )
+uncompress(tarfile.open(path, 'r:gz'), member, encoding)
 
-def parserCore( fp, pos, beginmark = None, endmark = None ):
+
+def parserCore(fp, pos, beginmark=None, endmark=None):
 if beginmark and endmark:
 start = False
-else: start = True
+else:
+start = True
 mlist = set()
 for line in fp:
-if beginmark and line.startswith( beginmark ):
+if beginmark and line.startswith(beginmark):
 start = True
 continue
-elif endmark and line.startswith( endmark ):
+elif endmark and line.startswith(endmark):
 break
-if start and not line.startswith( '#' ):
+if start and not line.startswith('#'):
 elems = line.split()
-if len( elems ) < 2:
+if len(elems) < 2:
 continue
-elif len( elems[0] ) > 1 and \
-len( elems[pos] ) > 1: # words only
-mlist.add( elems[pos] )
+elif len(elems[0]) > 1 and len(elems[pos]) > 1:  # words only
+mlist.add(elems[pos])
 return 

[MediaWiki-commits] [Gerrit] zhtable makefile: Remove unused variables, fix almost all pe... - change (mediawiki/core)

2015-10-16 Thread Chad (Code Review)
Chad has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/246808

Change subject: zhtable makefile: Remove unused variables, fix almost all pep8 
errors
..

zhtable makefile: Remove unused variables, fix almost all pep8 errors

Change-Id: I7ab1ffeeb2a5592fbe143f27801c11248c167093
---
M maintenance/language/zhtable/Makefile.py
1 file changed, 235 insertions(+), 207 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/08/246808/1

diff --git a/maintenance/language/zhtable/Makefile.py 
b/maintenance/language/zhtable/Makefile.py
index 4ab57d4..5924c66 100755
--- a/maintenance/language/zhtable/Makefile.py
+++ b/maintenance/language/zhtable/Makefile.py
@@ -1,9 +1,13 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 # @author Philip
-import tarfile as tf
-import zipfile as zf
-import os, re, shutil, sys, platform
+import os
+import platform
+import re
+import shutil
+import sys
+import tarfile
+import zipfile
 
 pyversion = platform.python_version()
 islinux = platform.system().lower() == 'linux'
@@ -18,16 +22,18 @@
 if i < 0x1:
 return _unichr(i)
 else:
-return _unichr( 0xD7C0 + ( i>>10 ) ) + _unichr( 0xDC00 + ( i & 
0x3FF ) )
+return _unichr(0xD7C0 + (i >> 10)) + _unichr(0xDC00 + (i & 
0x3FF))
 elif pyversion[:2] == '3.':
 import urllib.request as urllib_request
 unichr = chr
 
-def unichr2( *args ):
-return [unichr( int( i.split('<')[0][2:], 16 ) ) for i in args]
 
-def unichr3( *args ):
-return [unichr( int( i[2:7], 16 ) ) for i in args if i[2:7]]
+def unichr2(*args):
+return [unichr(int(i.split('<')[0][2:], 16)) for i in args]
+
+
+def unichr3(*args):
+return [unichr(int(i[2:7], 16)) for i in args if i[2:7]]
 
 # DEFINE
 UNIHAN_VER = '6.3.0'
@@ -37,189 +43,201 @@
 LIBTABE_VER = '0.2.3'
 # END OF DEFINE
 
-def download( url, dest ):
-if os.path.isfile( dest ):
-print( 'File %s is up to date.' % dest )
+
+def download(url, dest):
+if os.path.isfile(dest):
+print('File %s is up to date.' % dest)
 return
 global islinux
 if islinux:
-# we use wget instead urlretrieve under Linux, 
+# we use wget instead urlretrieve under Linux,
 # because wget could display details like download progress
-os.system( 'wget %s -O %s' % ( url, dest ) )
+os.system('wget %s -O %s' % (url, dest))
 else:
-print( 'Downloading from [%s] ...' % url )
-urllib_request.urlretrieve( url, dest )
-print( 'Download complete.\n' )
+print('Downloading from [%s] ...' % url)
+urllib_request.urlretrieve(url, dest)
+print('Download complete.\n')
 return
 
-def uncompress( fp, member, encoding = 'U8' ):
-name = member.rsplit( '/', 1 )[-1]
-print( 'Extracting %s ...' % name )
-fp.extract( member )
-shutil.move( member, name )
+
+def uncompress(fp, member, encoding='U8'):
+name = member.rsplit('/', 1)[-1]
+print('Extracting %s ...' % name)
+fp.extract(member)
+shutil.move(member, name)
 if '/' in member:
-shutil.rmtree( member.split( '/', 1 )[0] )
+shutil.rmtree(member.split('/', 1)[0])
 if pyversion[:1] in ['2']:
-fc = open( name, 'rb', encoding, 'ignore' )
+fc = open(name, 'rb', encoding, 'ignore')
 else:
-fc = open( name, 'r', encoding = encoding, errors = 'ignore' )
+fc = open(name, 'r', encoding=encoding, errors='ignore')
 return fc
 
 unzip = lambda path, member, encoding = 'U8': \
-uncompress( zf.ZipFile( path ), member, encoding )
+uncompress(zipfile.ZipFile(path), member, encoding)
 
 untargz = lambda path, member, encoding = 'U8': \
-uncompress( tf.open( path, 'r:gz' ), member, encoding )
+uncompress(tarfile.open(path, 'r:gz'), member, encoding)
 
-def parserCore( fp, pos, beginmark = None, endmark = None ):
+
+def parserCore(fp, pos, beginmark=None, endmark=None):
 if beginmark and endmark:
 start = False
-else: start = True
+else:
+start = True
 mlist = set()
 for line in fp:
-if beginmark and line.startswith( beginmark ):
+if beginmark and line.startswith(beginmark):
 start = True
 continue
-elif endmark and line.startswith( endmark ):
+elif endmark and line.startswith(endmark):
 break
-if start and not line.startswith( '#' ):
+if start and not line.startswith('#'):
 elems = line.split()
-if len( elems ) < 2:
+if len(elems) < 2:
 continue
-elif len( elems[0] ) > 1 and \
-len( elems[pos] ) > 1: # words only
-mlist.add( elems[pos] )
+elif len(elems[0]) > 1 and len(elems[pos]) > 1:  # words only
+mlist.add(elems[pos])