Skip to content

Commit

Permalink
Sort Python import (beeware#208)
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Holtermann <[email protected]>
  • Loading branch information
MarkusH authored and therealphildini committed Jul 23, 2016
1 parent 6e79b19 commit 52fa2c0
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 48 deletions.
13 changes: 12 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
[bdist_wheel]
universal=1
universal=1

[isort]
combine_as_imports = true
default_section = THIRDPARTY
include_trailing_comma = true
line_length = 79
multi_line_output = 5
not_skip = __init__.py
known_standard_library = marshal
known_first_party = voc
sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
3 changes: 2 additions & 1 deletion voc/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .transpiler import transpile
import argparse

from .transpiler import transpile


def main():
parser = argparse.ArgumentParser(
Expand Down
7 changes: 4 additions & 3 deletions voc/java/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import codecs

from . import mutf_8
from .attributes import *
from .klass import Class
from .constants import *
from .fields import Field
from .klass import Class
from .methods import Method
from .opcodes import *

# Register the MUTF-8 codec
import codecs
from voc.java import mutf_8
codecs.register(mutf_8.search_function)
3 changes: 2 additions & 1 deletion voc/java/attributes.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from collections import OrderedDict

from .constants import Utf8, Classref, NameAndType, Float, Integer
from .constants import Classref, Float, Integer, NameAndType, Utf8
from .opcodes import Opcode
from .signatures import method_descriptor


# From: http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html

##########################################################################
Expand Down
1 change: 1 addition & 0 deletions voc/java/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .signatures import method_descriptor


##########################################################################
# Some utility methods to help compare and hash constants
##########################################################################
Expand Down
3 changes: 2 additions & 1 deletion voc/java/fields.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .constants import Utf8
from .attributes import Attribute
from .constants import Utf8


# From: http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html

Expand Down
1 change: 1 addition & 0 deletions voc/java/klass.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .fields import Field
from .methods import Method


# From: http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html

##########################################################################
Expand Down
3 changes: 2 additions & 1 deletion voc/java/methods.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .constants import Utf8
from .attributes import Attribute
from .constants import Utf8


# From: http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html

Expand Down
5 changes: 3 additions & 2 deletions voc/java/mutf_8.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
"""

from __future__ import unicode_literals

import codecs
import re
from encodings import normalize_encoding
from encodings.utf_8 import (
IncrementalDecoder as UTF8IncrementalDecoder,
IncrementalEncoder as UTF8IncrementalEncoder,
)
import re
import codecs

# Match 6-byte CESU-9 sequences
CESU8_RE = re.compile(b'\xed[\xa0-\xaf][\x80-\xbf]\xed[\xb0-\xbf][\x80-\xbf]')
Expand Down
6 changes: 5 additions & 1 deletion voc/java/opcodes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from .constants import Classref, Fieldref, Methodref, InterfaceMethodref, String, Integer, Long, Float, Double, Constant
from .constants import (
Classref, Constant, Double, Fieldref, Float, Integer, InterfaceMethodref,
Long, Methodref, String,
)


# From: https://en.wikipedia.org/wiki/Java_bytecode_instruction_listings
# Reference" http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-6.html#jvms-6.2
Expand Down
2 changes: 1 addition & 1 deletion voc/java/signatures.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections import namedtuple
import re
from collections import namedtuple

# From: http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html

Expand Down
7 changes: 2 additions & 5 deletions voc/python/blocks.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import dis

from ..java import (
Code as JavaCode,
Code as JavaCode, ExceptionInfo as JavaExceptionInfo, LineNumberTable,
opcodes as JavaOpcodes,
ExceptionInfo as JavaExceptionInfo,
LineNumberTable
)

from .opcodes import ALOAD_name, ICONST_val, Opcode, Ref, jump, resolve_jump
from .utils import extract_command, find_blocks
from .opcodes import Ref, resolve_jump, jump, Opcode, ALOAD_name, ICONST_val


class IgnoreBlock(Exception):
Expand Down
19 changes: 7 additions & 12 deletions voc/python/klass.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import os

from ..java import (
Class as JavaClass,
Field as JavaField,
Method as JavaMethod,
Code as JavaCode,
opcodes as JavaOpcodes,
SourceFile,
RuntimeVisibleAnnotations,
Annotation,
ConstantElementValue,
Annotation, Class as JavaClass, Code as JavaCode, ConstantElementValue,
Field as JavaField, Method as JavaMethod, RuntimeVisibleAnnotations,
SourceFile, opcodes as JavaOpcodes,
)

from .blocks import Block, IgnoreBlock
from .methods import InitMethod, InstanceMethod, CO_GENERATOR, extract_parameters
from .opcodes import ASTORE_name, ALOAD_name, free_name
from .methods import (
CO_GENERATOR, InitMethod, InstanceMethod, extract_parameters,
)
from .opcodes import ALOAD_name, ASTORE_name, free_name


class ClassBlock(Block):
Expand Down
15 changes: 4 additions & 11 deletions voc/python/methods.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
from ..java import (
Code as JavaCode,
Method as JavaMethod,
opcodes as JavaOpcodes,
RuntimeVisibleAnnotations,
Annotation,
ConstantElementValue,
Annotation, Code as JavaCode, ConstantElementValue, Method as JavaMethod,
RuntimeVisibleAnnotations, opcodes as JavaOpcodes,
)

from .blocks import Block
from .opcodes import (
ALOAD_name, ASTORE_name, free_name,
ILOAD_name, FLOAD_name, DLOAD_name,
ICONST_val,
Opcode, TRY, CATCH, END_TRY,
CATCH, END_TRY, TRY, ALOAD_name, ASTORE_name, DLOAD_name, FLOAD_name,
ICONST_val, ILOAD_name, Opcode, free_name,
)

POSITIONAL_OR_KEYWORD = 1
Expand Down
11 changes: 5 additions & 6 deletions voc/python/modules.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import os

from ..java import (
Class as JavaClass,
Code as JavaCode,
Method as JavaMethod,
Class as JavaClass, Code as JavaCode, Method as JavaMethod, SourceFile,
opcodes as JavaOpcodes,
SourceFile,
)
from .blocks import Block, IgnoreBlock
from .methods import MainMethod, Method, CO_GENERATOR, GeneratorMethod, extract_parameters
from .opcodes import ASTORE_name, ALOAD_name, free_name
from .methods import (
CO_GENERATOR, GeneratorMethod, MainMethod, Method, extract_parameters,
)
from .opcodes import ALOAD_name, ASTORE_name, free_name


class ModuleBlock(Block):
Expand Down
3 changes: 1 addition & 2 deletions voc/python/opcodes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from ..java import opcodes as JavaOpcodes, Classref

from ..java import Classref, opcodes as JavaOpcodes

##########################################################################
# Pseudo instructions used to flag the offset position of other
Expand Down

0 comments on commit 52fa2c0

Please sign in to comment.