Skip to content

Commit

Permalink
Fix pep8 in Win+Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
KeyWeeUsr committed Sep 1, 2017
1 parent 075b6a5 commit d365a05
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 24 deletions.
6 changes: 4 additions & 2 deletions plyer/platforms/linux/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ def _get_state(self):

# We are supporting only one battery now
dev = "/org/freedesktop/UPower/device/battery_BAT0"
upower_process = Popen(["upower", "-d", dev],
stdout=PIPE)
upower_process = Popen(
["upower", "-d", dev],
stdout=PIPE
)
output = upower_process.communicate()[0]

environ['LANG'] = old_lang
Expand Down
4 changes: 2 additions & 2 deletions plyer/platforms/linux/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ def _send(self, **kwargs):
if recipient:
uri += str(recipient)
if subject:
uri += "?" if not "?" in uri else "&"
uri += "?" if "?" not in uri else "&"
uri += "subject="
uri += quote(str(subject))
if text:
uri += "?" if not "?" in uri else "&"
uri += "?" if "?" not in uri else "&"
uri += "body="
uri += quote(str(text))

Expand Down
5 changes: 3 additions & 2 deletions plyer/platforms/linux/filechooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def _gen_cmdline(self):
]
return cmdline


CHOOSERS = {
"gnome": ZenityFileChooser,
"kde": KDialogFileChooser,
Expand All @@ -225,8 +226,8 @@ class LinuxFileChooser(FileChooser):
'''

desktop = None
if str(os.environ.get("XDG_CURRENT_DESKTOP")).lower() == "kde" \
and which("kdialog"):
if (str(os.environ.get("XDG_CURRENT_DESKTOP")).lower() == "kde" and
which("kdialog")):
desktop = "kde"
elif which("yad"):
desktop = "yad"
Expand Down
7 changes: 5 additions & 2 deletions plyer/platforms/linux/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ def _notify(self, **kwargs):
session_bus = dbus.SessionBus()
obj = session_bus.get_object(_bus_name, _object_path)
interface = dbus.Interface(obj, _interface_name)
interface.Notify(app_name, replaces_id, app_icon,
summary, body, actions, hints, timeout * 1000)
interface.Notify(
app_name, replaces_id, app_icon,
summary, body, actions,
hints, timeout * 1000
)


def instance():
Expand Down
4 changes: 2 additions & 2 deletions plyer/platforms/win/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ def _send(self, **kwargs):
if recipient:
uri += str(recipient)
if subject:
uri += "?" if not "?" in uri else "&"
uri += "?" if "?" not in uri else "&"
uri += "subject="
uri += quote(str(subject))
if text:
uri += "?" if not "?" in uri else "&"
uri += "?" if "?" not in uri else "&"
uri += "body="
uri += quote(str(text))

Expand Down
5 changes: 4 additions & 1 deletion plyer/platforms/win/libs/batterystatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ def battery_status():
if not win_api_defs.GetSystemPowerStatus(ctypes.pointer(status)):
raise Exception('Could not get system power status.')

return dict((field, getattr(status, field)) for field, _ in status._fields_)
return dict(
(field, getattr(status, field))
for field, _ in status._fields_
)
28 changes: 20 additions & 8 deletions plyer/platforms/win/libs/wifi_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@


def customresize(array, new_size):
return (array._type_*new_size).from_address(addressof(array))
return (
array._type_ * new_size
).from_address(
addressof(array)
)


wlanapi = windll.LoadLibrary('wlanapi.dll')

Expand All @@ -22,8 +27,9 @@ class GUID(Structure):
('Data1', c_ulong),
('Data2', c_ushort),
('Data3', c_ushort),
('Data4', c_ubyte*8),
]
('Data4', c_ubyte * 8),
]


# The WLAN_INTERFACE_STATE enumerated type indicates the state of an interface.
WLAN_INTERFACE_STATE = c_uint
Expand All @@ -47,7 +53,7 @@ class WLAN_INTERFACE_INFO(Structure):
("InterfaceGuid", GUID),
("strInterfaceDescription", c_wchar * 256),
("isState", WLAN_INTERFACE_STATE)
]
]


class WLAN_INTERFACE_INFO_LIST(Structure):
Expand All @@ -59,9 +65,10 @@ class WLAN_INTERFACE_INFO_LIST(Structure):
("NumberOfItems", DWORD),
("Index", DWORD),
("InterfaceInfo", WLAN_INTERFACE_INFO * 1)
]
]

DOT11_MAC_ADDRESS = c_ubyte*6

DOT11_MAC_ADDRESS = c_ubyte * 6
WLAN_MAX_PHY_TYPE_NUMBER = 0x8
DOT11_SSID_MAX_LENGTH = 32
WLAN_REASON_CODE = DWORD
Expand Down Expand Up @@ -120,7 +127,8 @@ class DOT11_SSID(Structure):
_fields_ = [
("SSIDLength", c_ulong),
("SSID", c_char * DOT11_SSID_MAX_LENGTH)
]
]


# Enumerated type to define the code of connection.
WLAN_CONNECTION_MODE = c_uint
Expand Down Expand Up @@ -153,7 +161,8 @@ class DOT11_BSSID_LIST(Structure):
("Header", NDIS_OBJECT_HEADER),
("uNumOfEntries", ULONG),
("uTotalNumOfEntries", ULONG),
("BSSIDs", DOT11_MAC_ADDRESS*1)]
("BSSIDs", DOT11_MAC_ADDRESS * 1)
]


class WLAN_CONNECTION_PARAMETERS(Structure):
Expand All @@ -169,6 +178,7 @@ class WLAN_CONNECTION_PARAMETERS(Structure):
("dot11BssType", DOT11_BSS_TYPE),
("dwFlags", DWORD)]


# The `WlanConnect` attempts to connect to a specific network.
WlanConnect = wlanapi.WlanConnect
WlanConnect.argtypes = (HANDLE,
Expand Down Expand Up @@ -229,6 +239,7 @@ class WLAN_AVAILABLE_NETWORK_LIST(Structure):
("Index", DWORD),
("Network", WLAN_AVAILABLE_NETWORK * 1)]


# The WlanEnumInterfaces function enumerates all of the wireless LAN interfaces
# currently enabled on the local computer.
WlanEnumInterfaces = wlanapi.WlanEnumInterfaces
Expand Down Expand Up @@ -454,6 +465,7 @@ def _make_dict():
else:
_dict[network.dot11Ssid.SSID.decode('utf-8')] = network


def _get_available_wifi():
'''
returns the available wifi networks.
Expand Down
10 changes: 7 additions & 3 deletions plyer/platforms/win/libs/win_api_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@

import ctypes
from ctypes import Structure, windll, sizeof, POINTER, WINFUNCTYPE
from ctypes.wintypes import (DWORD, HICON, HWND, UINT, WCHAR, WORD, BYTE,
LPCWSTR, INT, LPVOID, HINSTANCE, HMENU, LPARAM, WPARAM,
HBRUSH, HMODULE, ATOM, BOOL, HANDLE)
from ctypes.wintypes import (
DWORD, HICON, HWND, UINT, WCHAR, WORD, BYTE,
LPCWSTR, INT, LPVOID, HINSTANCE, HMENU, LPARAM,
WPARAM, HBRUSH, HMODULE, ATOM, BOOL, HANDLE
)
LRESULT = LPARAM
HRESULT = HANDLE
HCURSOR = HICON
Expand Down Expand Up @@ -150,6 +152,7 @@ def get_WNDCLASSEXW(*largs):
wnd_class.cbSize = sizeof(WNDCLASSEXW)
return wnd_class


RegisterClassExW = windll.User32.RegisterClassExW
RegisterClassExW.argtypes = [POINTER(WNDCLASSEXW)]
RegisterClassExW.restype = ATOM
Expand Down Expand Up @@ -193,6 +196,7 @@ class SYSTEM_POWER_STATUS(Structure):
('BatteryFullLifeTime', DWORD),
]


SystemPowerStatusP = POINTER(SYSTEM_POWER_STATUS)

GetSystemPowerStatus = windll.kernel32.GetSystemPowerStatus
Expand Down
6 changes: 4 additions & 2 deletions plyer/platforms/win/uniqueid.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@

class WinUniqueID(UniqueID):
def _get_uid(self):
hKey = regedit.OpenKey(regedit.HKEY_LOCAL_MACHINE,
hKey = regedit.OpenKey(
regedit.HKEY_LOCAL_MACHINE,
r"SOFTWARE\\Microsoft\\Cryptography", 0,
regedit.KEY_READ | regedit.KEY_WOW64_64KEY)
regedit.KEY_READ | regedit.KEY_WOW64_64KEY
)
value, _ = regedit.QueryValueEx(hKey, "MachineGuid")
return value

Expand Down

0 comments on commit d365a05

Please sign in to comment.