Skip to content

Commit

Permalink
fix(#7): use relative imports
Browse files Browse the repository at this point in the history
  • Loading branch information
h2non committed Jul 31, 2016
1 parent 713d2f1 commit e84831b
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 28 deletions.
6 changes: 3 additions & 3 deletions filetype/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-

from filetype.match import * # noqa
from filetype.helpers import * # noqa
from filetype.filetype import * # noqa
from .match import * # noqa
from .helpers import * # noqa
from .filetype import * # noqa

# Current package semver version
__version__ = version = '0.1.1'
4 changes: 2 additions & 2 deletions filetype/filetype.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

from filetype import match
from filetype.types import types
from .match import match
from .types import types

# Expose supported matchers types
types = types
Expand Down
4 changes: 2 additions & 2 deletions filetype/helpers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

from filetype.types import types
from filetype import match
from .types import types
from .match import match


def is_extension_supported(ext):
Expand Down
27 changes: 17 additions & 10 deletions filetype/match.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# -*- coding: utf-8 -*-

from filetype import types
from filetype.utils import get_bytes


def match(obj, matchers=types.types):
from .utils import get_bytes
from .types import (
types,
image as image_matchers,
video as video_matchers,
font as font_matchers,
archive as archive_matchers,
audio as audio_matchers
)


def match(obj, matchers=types):
"""
Matches the given input againts the available
file type matchers.
Expand Down Expand Up @@ -41,7 +48,7 @@ def image(obj):
Raises:
TypeError: if obj is not a supported type.
"""
return match(obj, types.image)
return match(obj, image_matchers)


def font(obj):
Expand All @@ -58,7 +65,7 @@ def font(obj):
Raises:
TypeError: if obj is not a supported type.
"""
return match(obj, types.font)
return match(obj, font_matchers)


def video(obj):
Expand All @@ -75,7 +82,7 @@ def video(obj):
Raises:
TypeError: if obj is not a supported type.
"""
return match(obj, types.video)
return match(obj, video_matchers)


def audio(obj):
Expand All @@ -92,7 +99,7 @@ def audio(obj):
Raises:
TypeError: if obj is not a supported type.
"""
return match(obj, types.audio)
return match(obj, audio_matchers)


def archive(obj):
Expand All @@ -109,4 +116,4 @@ def archive(obj):
Raises:
TypeError: if obj is not a supported type.
"""
return match(obj, types.archive)
return match(obj, archive_matchers)
12 changes: 6 additions & 6 deletions filetype/types/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-

from filetype.types import font
from filetype.types import image
from filetype.types import video
from filetype.types import audio
from filetype.types import archive
from filetype.types.base import Type # noqa
from . import font
from . import image
from . import video
from . import audio
from . import archive
from .base import Type # noqa

# Supported image types
image = (
Expand Down
2 changes: 1 addition & 1 deletion filetype/types/archive.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from filetype.types.base import Type
from .base import Type


class Epub(Type):
Expand Down
2 changes: 1 addition & 1 deletion filetype/types/audio.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from filetype.types.base import Type
from .base import Type


class Midi(Type):
Expand Down
2 changes: 1 addition & 1 deletion filetype/types/font.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from filetype.types.base import Type
from .base import Type


class Woff(Type):
Expand Down
2 changes: 1 addition & 1 deletion filetype/types/image.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from filetype.types.base import Type
from .base import Type


class Jpeg(Type):
Expand Down
2 changes: 1 addition & 1 deletion filetype/types/video.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from filetype.types.base import Type
from .base import Type


class Mp4(Type):
Expand Down

0 comments on commit e84831b

Please sign in to comment.