Browse Source

Apply PEP8 formatting fixes

Fix formatting according to PEP8
pull/8/head
George Vlahavas 9 years ago
parent
commit
7e5e51459a
  1. 40
      src/xdgmenumaker

40
src/xdgmenumaker

@ -38,6 +38,7 @@ class App:
''' '''
A class to keep individual app details in. A class to keep individual app details in.
''' '''
def __init__(self, name, icon, command, path): def __init__(self, name, icon, command, path):
self.name = name self.name = name
self.icon = icon self.icon = icon
@ -46,26 +47,30 @@ class App:
def __repr__(self): def __repr__(self):
return repr((self.name, self.icon, self.command, return repr((self.name, self.icon, self.command,
self.path)) self.path))
class MenuEntry: class MenuEntry:
''' '''
A class for each menu entry. Includes the class category and app details A class for each menu entry. Includes the class category and app details
from the App class. from the App class.
''' '''
def __init__(self, category, app): def __init__(self, category, app):
self.category = category self.category = category
self.app = app self.app = app
def __repr__(self): def __repr__(self):
return repr((self.category, self.app.name, self.app.icon, return repr((self.category, self.app.name, self.app.icon,
self.app.command, self.app.path)) self.app.command, self.app.path))
class MenuCategory: class MenuCategory:
''' '''
A class for each menu category. Keeps the category name and the list of A class for each menu category. Keeps the category name and the list of
apps that go in that category. apps that go in that category.
''' '''
def __init__(self, category, applist): def __init__(self, category, applist):
self.category = category self.category = category
self.applist = applist self.applist = applist
@ -271,7 +276,6 @@ def get_entry_info(desktopfile, ico_paths=True):
else: else:
icon = None icon = None
# removing any %U or %F from the exec line # removing any %U or %F from the exec line
command = de.getExec().partition('%')[0] command = de.getExec().partition('%')[0]
@ -409,6 +413,7 @@ def category_icon(category):
icon = None icon = None
return icon return icon
def blackbox(): def blackbox():
# Blackbox menus are the same as Fluxbox menus. They just don't support # Blackbox menus are the same as Fluxbox menus. They just don't support
# icons. # icons.
@ -416,6 +421,7 @@ def blackbox():
seticon = False seticon = False
fluxbox() fluxbox()
def fluxbox(): def fluxbox():
if submenu: if submenu:
spacing = ' ' spacing = ' '
@ -503,7 +509,7 @@ def icewm():
command = app.command command = app.command
if seticon and icon is not None: if seticon and icon is not None:
print('{s} prog "{n}" {i} {c}'.format(s=spacing, n=name, print('{s} prog "{n}" {i} {c}'.format(s=spacing, n=name,
i=icon, c=command)) i=icon, c=command))
else: else:
print('{s} prog "{n}" _none_ {c}'.format(s=spacing, n=name, print('{s} prog "{n}" _none_ {c}'.format(s=spacing, n=name,
c=command)) c=command))
@ -540,7 +546,7 @@ def pekwmmenu():
i=cat_icon)) i=cat_icon))
else: else:
print('{d}{s}Submenu = "{c}" {{'.format(d=dspacing, s=spacing, print('{d}{s}Submenu = "{c}" {{'.format(d=dspacing, s=spacing,
c=category)) c=category))
for app in menu_category.applist: for app in menu_category.applist:
name = app.name name = app.name
icon = app.icon icon = app.icon
@ -557,11 +563,11 @@ def pekwmmenu():
command = 'cd {p} && {c} || {c}'.format(p=path, c=command) command = 'cd {p} && {c} || {c}'.format(p=path, c=command)
if seticon and icon is not None: if seticon and icon is not None:
print('{d}{s} Entry = "{n}" {{ Icon = "{i}"; Actions = "Exec {c} &" }}' print('{d}{s} Entry = "{n}" {{ Icon = "{i}"; Actions = "Exec {c} &" }}'
.format(d=dspacing, s=spacing, n=name, i=icon, .format(d=dspacing, s=spacing, n=name, i=icon,
c=command)) c=command))
else: else:
print('{d}{s} Entry = "{n}" {{ Actions = "Exec {c} &" }}' print('{d}{s} Entry = "{n}" {{ Actions = "Exec {c} &" }}'
.format(d=dspacing, s=spacing, n=name, c=command)) .format(d=dspacing, s=spacing, n=name, c=command))
print('{d}{s}}}'.format(d=dspacing, s=spacing)) print('{d}{s}}}'.format(d=dspacing, s=spacing))
if submenu: if submenu:
print('{}}}'.format(dspacing)) print('{}}}'.format(dspacing))
@ -604,15 +610,16 @@ def jwm():
command = 'cd {p} ; {c}'.format(p=path, c=command) command = 'cd {p} ; {c}'.format(p=path, c=command)
if seticon and icon is not None: if seticon and icon is not None:
print('{s} <Program icon="{i}" label="{n}">{c}</Program>' print('{s} <Program icon="{i}" label="{n}">{c}</Program>'
.format(s=spacing, i=icon, n=name, c=command)) .format(s=spacing, i=icon, n=name, c=command))
else: else:
print('{s} <Program label="{n}">{c}</Program>' print('{s} <Program label="{n}">{c}</Program>'
.format(s=spacing, n=name, c=command)) .format(s=spacing, n=name, c=command))
print('{}</Menu>'.format(spacing)) print('{}</Menu>'.format(spacing))
if submenu: if submenu:
print('</Menu>') print('</Menu>')
print('</JWM>') print('</JWM>')
def compizboxmenu(): def compizboxmenu():
if submenu: if submenu:
spacing = ' ' spacing = ' '
@ -628,7 +635,8 @@ def compizboxmenu():
category = menu_category.category category = menu_category.category
cat_icon = category_icon(category) cat_icon = category_icon(category)
if seticon and cat_icon is not None: if seticon and cat_icon is not None:
print('{s}<menu icon="{i}" name="{c}">'.format(s=spacing, i=cat_icon, c=category)) print('{s}<menu icon="{i}" name="{c}">'.format(
s=spacing, i=cat_icon, c=category))
else: else:
print('{s}<menu name="{c}">'.format(s=spacing, c=category)) print('{s}<menu name="{c}">'.format(s=spacing, c=category))
for app in menu_category.applist: for app in menu_category.applist:
@ -641,13 +649,13 @@ def compizboxmenu():
command = 'sh -c \'cd "{p}" ;{c}\''.format(p=path, c=command) command = 'sh -c \'cd "{p}" ;{c}\''.format(p=path, c=command)
if seticon and icon is not None: if seticon and icon is not None:
print(('{s} <item type="launcher"><name>{n}</name>' print(('{s} <item type="launcher"><name>{n}</name>'
'<icon>{i}</icon>' '<icon>{i}</icon>'
'<command>{c}</command></item>').format(s=spacing, '<command>{c}</command></item>').format(s=spacing,
n=name, i=icon, c=command)) n=name, i=icon, c=command))
else: else:
print(('{s} <item type="launcher"><name>{n}</name>' print(('{s} <item type="launcher"><name>{n}</name>'
'<command>{c}</command></item>').format(s=spacing, '<command>{c}</command></item>').format(s=spacing,
n=name, c=command)) n=name, c=command))
print('{}</menu>'.format(spacing)) print('{}</menu>'.format(spacing))
if submenu: if submenu:
print('</menu>') print('</menu>')

Loading…
Cancel
Save