Skip to content

Commit 19b3391

Browse files
authored
Use relative imports (#102)
1 parent dac24b4 commit 19b3391

File tree

5 files changed

+20
-28
lines changed

5 files changed

+20
-28
lines changed

editorconfig/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""EditorConfig Python Core"""
22

3-
from editorconfig.versiontools import join_version
3+
from .versiontools import join_version
44

55
VERSION = (0, 12, 2, "final")
66

@@ -15,5 +15,5 @@ def get_properties(filename):
1515
return handler.get_configurations()
1616

1717

18-
from editorconfig.handler import EditorConfigHandler
19-
from editorconfig.exceptions import *
18+
from .handler import EditorConfigHandler
19+
from .exceptions import *

editorconfig/handler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
import os
1111

12-
from editorconfig import VERSION
13-
from editorconfig.exceptions import PathError, VersionError
14-
from editorconfig.ini import EditorConfigParser
12+
from . import VERSION
13+
from .exceptions import PathError, VersionError
14+
from .ini import EditorConfigParser
1515

1616

1717
__all__ = ['EditorConfigHandler']

editorconfig/ini.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
from os import sep
2121
from os.path import dirname, normpath
2222

23-
from editorconfig.compat import u
24-
from editorconfig.exceptions import ParsingError
25-
from editorconfig.fnmatch import fnmatch
23+
from .compat import u
24+
from .exceptions import ParsingError
25+
from .fnmatch import fnmatch
2626

2727

2828
__all__ = ["ParsingError", "EditorConfigParser"]

editorconfig/main.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
import getopt
88
import sys
99

10-
from editorconfig import VERSION, __version__
11-
from editorconfig.compat import force_unicode
12-
from editorconfig.exceptions import ParsingError, PathError, VersionError
13-
from editorconfig.handler import EditorConfigHandler
14-
from editorconfig.versiontools import split_version
10+
from . import VERSION, __version__
11+
from .compat import force_unicode
12+
from .exceptions import ParsingError, PathError, VersionError
13+
from .handler import EditorConfigHandler
14+
from .versiontools import split_version
1515

1616

1717
def version():

EditorConfig.py renamed to plugin.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
11
import pprint
22
import sublime
33
import sublime_plugin
4-
5-
def unexpanduser(path):
6-
from os.path import expanduser
7-
return path.replace(expanduser('~'), '~')
8-
9-
try:
10-
import os, sys
11-
# stupid python module system
12-
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
13-
from .editorconfig import get_properties, EditorConfigError
14-
except:
15-
# Python 2
16-
from editorconfig import get_properties, EditorConfigError
4+
from .editorconfig import get_properties, EditorConfigError
175

186
LINE_ENDINGS = {
197
'lf': 'unix',
@@ -29,6 +17,10 @@ def unexpanduser(path):
2917
'utf-16le': 'utf-16 le'
3018
}
3119

20+
def unexpanduser(path):
21+
from os.path import expanduser
22+
return path.replace(expanduser('~'), '~')
23+
3224
def log(msg):
3325
print('EditorConfig: %s' % msg)
3426

@@ -119,5 +111,5 @@ def apply_config(self, view, config):
119111

120112
class RemoveFinalNewlinesCommand(sublime_plugin.TextCommand):
121113
def run(self, edit):
122-
region = self.view.find('\n*\Z', 0)
114+
region = self.view.find(r'\n*\Z', 0)
123115
self.view.erase(edit, region)

0 commit comments

Comments
 (0)