Skip to content

Commit

Permalink
Fix pep8 failures, and apply black formatting where applicable. (kivy…
Browse files Browse the repository at this point in the history
  • Loading branch information
misl6 authored Dec 8, 2023
1 parent d16addd commit 47fbce1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
7 changes: 6 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
# built documents.
#


# Lookup the version from the pyjnius module, without installing it
# since readthedocs.org may have issue to install it.
# Read the version from the __init__.py file, without importing it.
Expand All @@ -64,10 +65,14 @@ def get_version():
os.path.join(os.path.abspath("../.."), "plyer", "__init__.py")
) as fp:
for line in fp:
m = re.search(r'^\s*__version__\s*=\s*([\'"])([^\'"]+)\1\s*$', line)
m = re.search(
r'^\s*__version__\s*=\s*([\'"])([^\'"]+)\1\s*$',
line,
)
if m:
return m.group(2)


# The short X.Y version.
version = get_version()
# The full version, including alpha/beta/rc tags.
Expand Down
16 changes: 10 additions & 6 deletions plyer/platforms/android/filechooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,11 @@ def _open_file(self, **kwargs):

# create Intent for opening
file_intent = Intent(Intent.ACTION_GET_CONTENT)
if not self.selected_mime_type or \
type(self.selected_mime_type) != str or \
self.selected_mime_type not in self.mime_type:
if (
not self.selected_mime_type
or not isinstance(self.selected_mime_type, str)
or self.selected_mime_type not in self.mime_type
):
file_intent.setType("*/*")
else:
file_intent.setType(self.mime_type[self.selected_mime_type])
Expand Down Expand Up @@ -176,9 +178,11 @@ def _save_file(self, **kwargs):
kwargs.pop("filters")[0] if "filters" in kwargs else ""

file_intent = Intent(Intent.ACTION_CREATE_DOCUMENT)
if not self.selected_mime_type or \
type(self.selected_mime_type) != str or \
self.selected_mime_type not in self.mime_type:
if (
not self.selected_mime_type
or not isinstance(self.selected_mime_type, str)
or self.selected_mime_type not in self.mime_type
):
file_intent.setType("*/*")
else:
file_intent.setType(self.mime_type[self.selected_mime_type])
Expand Down
6 changes: 3 additions & 3 deletions plyer/platforms/linux/filechooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def _gen_cmdline(self):
if self.icon:
cmdline += ["--window-icon", self.icon]
for f in self.filters:
if type(f) == str:
if isinstance(f, str):
cmdline += ["--file-filter", f]
else:
cmdline += [
Expand Down Expand Up @@ -150,7 +150,7 @@ def _gen_cmdline(self):
filt = []

for f in self.filters:
if type(f) == str:
if isinstance(f, str):
filt += [f]
else:
filt += list(f[1:])
Expand Down Expand Up @@ -215,7 +215,7 @@ def _gen_cmdline(self):
if self.icon:
cmdline += ["--window-icon", self.icon]
for f in self.filters:
if type(f) == str:
if isinstance(f, str):
cmdline += ["--file-filter", f]
else:
cmdline += [
Expand Down
2 changes: 1 addition & 1 deletion plyer/platforms/macosx/filechooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def run(self):
if self.filters:
filthies = []
for f in self.filters:
if type(f) == str:
if isinstance(f, str):
f = (None, f)
for s in f[1:]:
if not self.use_extensions:
Expand Down
2 changes: 1 addition & 1 deletion plyer/platforms/win/filechooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def run(self):
# e.g. open_file(filters=['*.txt', '*.py'])
filters = ""
for f in self.filters:
if type(f) == str:
if isinstance(f, str):
filters += (f + "\x00") * 2
else:
filters += f[0] + "\x00" + ";".join(f[1:]) + "\x00"
Expand Down

0 comments on commit 47fbce1

Please sign in to comment.