Mercurial > hg > config
changeset 498:95ba5770d2f0
file decorator
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 21 Aug 2013 15:54:09 -0700 |
parents | 2e51a55d303d |
children | 84a865a880a8 |
files | .fluxbox/init python/fileobj.py |
diffstat | 2 files changed, 126 insertions(+), 80 deletions(-) [+] |
line wrap: on
line diff
--- a/.fluxbox/init Wed Aug 14 10:25:08 2013 -0700 +++ b/.fluxbox/init Wed Aug 21 15:54:09 2013 -0700 @@ -1,111 +1,111 @@ -session.screen0.rootCommand: fbsetbg ~/image/wallpaper +session.screen0.window.focus.alpha: 122 +session.screen0.window.unfocus.alpha: 47 +session.screen0.menu.alpha: 82 +session.screen0.tab.alignment: Left +session.screen0.tab.width: 0 +session.screen0.tab.rotatevertical: True +session.screen0.tab.placement: TopLeft +session.screen0.tab.height: 0 +session.screen0.clientMenu.usePixmap: true +session.screen0.slit.direction: Vertical +session.screen0.slit.maxOver: true +session.screen0.slit.onhead: 0 +session.screen0.slit.placement: RightBottom +session.screen0.slit.alpha: 255 +session.screen0.slit.autoHide: false +session.screen0.slit.onTop: False +session.screen0.slit.layer: Bottom +session.screen0.slit.acceptKdeDockapps: true +session.screen0.iconbar.iconWidth: 70 +session.screen0.iconbar.wheelMode: Screen +session.screen0.iconbar.alignment: Relative +session.screen0.iconbar.mode: {static groups} (workspace) +session.screen0.iconbar.usePixmap: true +session.screen0.iconbar.iconTextPadding: 10 +session.screen0.iconbar.deiconifyMode: Follow +session.screen0.toolbar.visible: true +session.screen0.toolbar.maxOver: true +session.screen0.toolbar.alpha: 50 +session.screen0.toolbar.onhead: 0 +session.screen0.toolbar.widthPercent: 44 +session.screen0.toolbar.placement: BottomCenter +session.screen0.toolbar.tools: workspacename, iconbar, systemtray, clock +session.screen0.toolbar.onTop: False +session.screen0.toolbar.autoHide: false +session.screen0.toolbar.layer: Desktop +session.screen0.toolbar.height: 0 session.screen0.titlebar.left: Stick session.screen0.titlebar.right: Minimize Maximize Close -session.screen0.clientMenu.usePixmap: true -session.screen0.menu.alpha: 82 -session.screen0.slit.acceptKdeDockapps: true -session.screen0.slit.maxOver: true -session.screen0.slit.placement: RightBottom -session.screen0.slit.alpha: 255 -session.screen0.slit.onTop: False -session.screen0.slit.layer: Bottom -session.screen0.slit.direction: Vertical -session.screen0.slit.onhead: 0 -session.screen0.slit.autoHide: false session.screen0.tabs.intitlebar: true session.screen0.tabs.maxOver: false session.screen0.tabs.usePixmap: false -session.screen0.tab.width: 0 -session.screen0.tab.height: 0 -session.screen0.tab.alignment: Left -session.screen0.tab.placement: TopLeft -session.screen0.tab.rotatevertical: True -session.screen0.iconbar.iconTextPadding: 10 -session.screen0.iconbar.wheelMode: Screen -session.screen0.iconbar.usePixmap: true -session.screen0.iconbar.mode: {static groups} (workspace) -session.screen0.iconbar.iconWidth: 70 -session.screen0.iconbar.alignment: Relative -session.screen0.iconbar.deiconifyMode: Follow -session.screen0.window.focus.alpha: 122 -session.screen0.window.unfocus.alpha: 47 -session.screen0.toolbar.visible: true -session.screen0.toolbar.maxOver: true -session.screen0.toolbar.widthPercent: 44 -session.screen0.toolbar.placement: BottomCenter -session.screen0.toolbar.alpha: 50 -session.screen0.toolbar.onTop: False -session.screen0.toolbar.tools: workspacename, iconbar, systemtray, clock -session.screen0.toolbar.height: 0 -session.screen0.toolbar.layer: Desktop -session.screen0.toolbar.autoHide: false -session.screen0.toolbar.onhead: 0 session.screen0.overlay.lineWidth: 1 session.screen0.overlay.lineStyle: LineSolid session.screen0.overlay.joinStyle: JoinMiter session.screen0.overlay.capStyle: CapNotLast -session.screen0.menuDelay: 0 -session.screen0.sloppywindowgrouping: true -session.screen0.autoRaise: false -session.screen0.resizeMode: Bottom -session.screen0.edgeSnapThreshold: 0 -session.screen0.followModel: Ignore -session.screen0.noFocusWhileTypingDelay: 0 -session.screen0.decorateTransient: true +session.screen0.focusNewWindows: true session.screen0.fullMaximization: true +session.screen0.colPlacementDirection: TopToBottom session.screen0.maxIgnoreIncrement: true -session.screen0.allowRemoteActions: false -session.screen0.tabFocusModel: ClickToTabFocus -session.screen0.defaultDeco: NORMAL -session.screen0.tooltipDelay: 500 -session.screen0.focusModel: MouseFocus -session.screen0.workspaceNames: one,two,three,four,five,six, -session.screen0.windowScrollReverse: false -session.screen0.imageDither: false -session.screen0.strftimeFormat: %k:%M -session.screen0.rowPlacementDirection: LeftToRight -session.screen0.reversewheeling: false -session.screen0.menuMode: Delay -session.screen0.showwindowposition: true -session.screen0.maxDisableResize: false -session.screen0.focusNewWindows: true -session.screen0.colPlacementDirection: TopToBottom session.screen0.desktopwheeling: true +session.screen0.allowRemoteActions: false session.screen0.windowScrollAction: +session.screen0.tabFocusModel: ClickToTabFocus session.screen0.focusLastWindow: true +session.screen0.defaultDeco: NORMAL session.screen0.maxDisableMove: false +session.screen0.tooltipDelay: 500 session.screen0.clickRaises: true +session.screen0.focusModel: MouseFocus session.screen0.windowPlacement: RowSmartPlacement +session.screen0.workspaceNames: one,two,three,four,five,six, +session.screen0.menuDelay: 0 +session.screen0.windowScrollReverse: false +session.screen0.userFollowModel: Follow +session.screen0.imageDither: false +session.screen0.sloppywindowgrouping: true +session.screen0.workspaces: 6 +session.screen0.strftimeFormat: %k:%M +session.screen0.autoRaise: false +session.screen0.workspacewarping: true +session.screen0.rowPlacementDirection: LeftToRight +session.screen0.resizeMode: Bottom +session.screen0.windowMenu: +session.screen0.reversewheeling: false +session.screen0.edgeSnapThreshold: 0 +session.screen0.antialias: true session.screen0.rootCommand: fbsetbg ~/image/wallpaper -session.screen0.userFollowModel: Follow -session.screen0.workspaces: 6 -session.screen0.workspacewarping: true -session.screen0.windowMenu: -session.screen0.antialias: true +session.screen0.menuMode: Delay +session.screen0.followModel: Ignore session.screen0.opaqueMove: false +session.screen0.showwindowposition: true +session.screen0.noFocusWhileTypingDelay: 0 session.screen0.demandsAttentionTimeout: 500 +session.screen0.maxDisableResize: false +session.screen0.decorateTransient: true session.screen0.menuDelayClose: 0 +session.groupFile: ~/.fluxbox/groups session.cacheLife: 5 +session.useMod1: true +session.autoRaiseDelay: 250 +session.imageDither: True session.configVersion: 13 -session.imageDither: True +session.keyFile: ~/.fluxbox/keys session.styleOverlay: ~/.fluxbox/overlay -session.menuFile: ~/.fluxbox/menu -session.focusTabMinWidth: 0 -session.doubleClickInterval: 250 -session.colorsPerChannel: 4 -session.tabs: false -session.numLayers: 13 -session.groupFile: ~/.fluxbox/groups -session.autoRaiseDelay: 250 +session.ignoreBorder: false session.forcePseudoTransparency: true session.appsFile: ~/.fluxbox/apps +session.menuFile: ~/.fluxbox/menu +session.styleFile: ~/.fluxbox/styles/Black session.tabPadding: 0 +session.focusTabMinWidth: 0 +session.tabsAttachArea: Window session.cacheMax: 200 +session.doubleClickInterval: 250 +session.opaqueMove: False session.modKey: Mod1 +session.colorsPerChannel: 4 +session.numLayers: 13 +session.tabs: false session.slitlistFile: ~/.fluxbox/slitlist -session.useMod1: true -session.keyFile: ~/.fluxbox/keys -session.ignoreBorder: false -session.opaqueMove: False -session.styleFile: ~/.fluxbox/styles/Black -session.tabsAttachArea: Window
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/fileobj.py Wed Aug 21 15:54:09 2013 -0700 @@ -0,0 +1,46 @@ +#!/usr/bin/env python + +""" +filename -> file-like object as a decorator +""" + +import optparse +import os +import sys + +string = (basestring,) + +class fileobj(object): + def __init__(self, arg, *args, **kwargs): + self._args = [arg] + list(args) + self._kwargs = kwargs + # mode, filename, ... + + # function + self.func = arg if not args else None + def __call__(self, *args, **kwargs): + if self.func is None: + raise NotImplementedError + else: + if len(args) and isinstance(args[0], string): + args = list(args) + with file(args[0], 'w') as fp: + args[0] =fp + return self.func(*args, **kwargs) + return self.func(*args, **kwargs) + +if __name__ == '__main__': + # test code + import os + import tempfile + + @fileobj + def test1(fp): + fp.write('foo') + + filename = tempfile.mktemp() + print filename + assert not os.path.exists(filename) + test1(filename) + assert os.path.exists(filename) + print file(filename).read()