Skip to content

Commit e1b154c

Browse files
committed
Run ruff format
1 parent c8a599b commit e1b154c

3 files changed

Lines changed: 20 additions & 14 deletions

File tree

magic/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def __init__(
114114
if magic_file is None and not os.environ.get("MAGIC"):
115115
# wheels package the mime database in this directory
116116
# prefer it when no magic file is specified by the user
117-
mime_db = os.path.join(os.path.dirname(__file__), 'magic.mgc')
117+
mime_db = os.path.join(os.path.dirname(__file__), "magic.mgc")
118118
if os.path.exists(mime_db):
119119
magic_file = mime_db
120120
magic_load(self.cookie, magic_file)

magic/loader.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,22 @@
1212

1313
def _lib_candidates_linux():
1414
"""Yield possible libmagic library names on Linux."""
15-
fnames = ('libmagic.so.1', 'libmagic.so')
15+
fnames = ("libmagic.so.1", "libmagic.so")
1616

1717
for fname in fnames:
1818
# libmagic bundled in the wheel
1919
yield os.path.join(here, fname)
2020
# libmagic in the current working directory
21-
yield os.path.join(os.path.abspath('.'), fname)
21+
yield os.path.join(os.path.abspath("."), fname)
2222
# libmagic install from source default destination path
23-
yield os.path.join('/usr/local/lib', fname)
23+
yield os.path.join("/usr/local/lib", fname)
2424
# on some linux systems (musl/alpine), find_library('magic') returns None
2525
# first try finding libmagic using ldconfig
2626
# otherwise fall back to /usr/lib/
2727
yield subprocess.check_output(
28-
"( ldconfig -p | grep '{0}' | grep -o '/.*' ) || echo '/usr/lib/{0}'".format(fname),
28+
"( ldconfig -p | grep '{0}' | grep -o '/.*' ) || echo '/usr/lib/{0}'".format(
29+
fname
30+
),
2931
shell=True,
3032
universal_newlines=True,
3133
).strip()
@@ -37,15 +39,15 @@ def _lib_candidates_macos():
3739
# libmagic bundled in the wheel
3840
here,
3941
# libmagic in the current working directory
40-
os.path.abspath('.'),
42+
os.path.abspath("."),
4143
# libmagic in other common sources like homebrew
42-
'/opt/local/lib',
43-
'/usr/local/lib',
44-
'/opt/homebrew/lib',
45-
] + glob.glob('/usr/local/Cellar/libmagic/*/lib')
44+
"/opt/local/lib",
45+
"/usr/local/lib",
46+
"/opt/homebrew/lib",
47+
] + glob.glob("/usr/local/Cellar/libmagic/*/lib")
4648

4749
for path in paths:
48-
yield os.path.join(path, 'libmagic.dylib')
50+
yield os.path.join(path, "libmagic.dylib")
4951

5052

5153
def _lib_candidates_windows():
@@ -61,9 +63,9 @@ def _lib_candidates_windows():
6163

6264
for fname in fnames:
6365
# libmagic bundled in the wheel
64-
yield os.path.join(here, '%s.dll' % fname)
66+
yield os.path.join(here, "%s.dll" % fname)
6567
# libmagic in the current working directory
66-
yield os.path.join(os.path.abspath('.'), '%s.dll' % fname)
68+
yield os.path.join(os.path.abspath("."), "%s.dll" % fname)
6769
# find_library searches in %PATH% but not the current directory
6870
yield find_library(fname)
6971

@@ -83,7 +85,7 @@ def _lib_candidates():
8385
yield path
8486

8587
# fallback
86-
yield find_library('magic')
88+
yield find_library("magic")
8789

8890

8991
def load_lib():

setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@
88

99
# python packages should not install succesfully if libraries are missing
1010
from magic.loader import load_lib
11+
1112
load_lib()._name
1213

14+
1315
def read(file_name):
1416
"""Read a text file and return the content as a string."""
1517
with io.open(
1618
os.path.join(os.path.dirname(__file__), file_name), encoding="utf-8"
1719
) as f:
1820
return f.read()
1921

22+
2023
def get_cmdclass():
2124
"""Build a platform-specific wheel when `setup.py bdist_wheel` is called."""
2225
if sys.version_info[0] == 2:
@@ -37,6 +40,7 @@ def get_tag(self):
3740

3841
return {"bdist_wheel": bdist_wheel_platform_specific}
3942

43+
4044
cmdclass = get_cmdclass()
4145

4246
setuptools.setup(

0 commit comments

Comments
 (0)