From 4023dff63680db0d6c24910824873fcca99bccb4 Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 22 Nov 2011 16:28:53 +0100 Subject: [PATCH] removed template stuff --- afo.py | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/afo.py b/afo.py index 6b6ddaf..fd72c5c 100755 --- a/afo.py +++ b/afo.py @@ -13,12 +13,6 @@ # $args = the list of positional arguments passed to afo # $a0..$a999 = one specific argument passed to afo # -# There is another variable that refers to other ways of opening the file. -# It is no real environment variable; it will be substituted before passing -# to the shell and can be escaped by replacing '%' with '%%'. -# -# %w = replaced with the way of opening this file -# # ----------------------------------------------------- # Configuration file: # @@ -59,7 +53,6 @@ import optparse import os.path import re import subprocess -import string import sys try: import yaml @@ -69,10 +62,6 @@ except ImportError: def _shell_quote(string): return "'" + string.replace("'", "'\''") + "'" -class _Template(string.Template): - delimiter = '%' - idpattern = r'W[0-9a-zA-Z]+' - class AFO(object): def __init__(self, file, options=[], ways=[0], list_ways=False, args=[]): self.__dict__.update(locals()) @@ -108,9 +97,9 @@ class AFO(object): if isinstance(program, str): return {'0': program} elif isinstance(program, dict): - return dict(map((lambda k,v: (str(k), v)), program)) + return dict(map((lambda v: (str(v[0]), v[1])), program.items())) elif isinstance(program, list): - return dict(map((lambda k,v: (str(k), v)), enumerate(program))) + return dict(map((lambda v: (str(v[0]), v[1])), enumerate(program))) def _load_config(self): basedir = os.path.expanduser(os.getenv('XDG_CONFIG_PATH', '~/.config')) @@ -128,7 +117,7 @@ class AFO(object): else: for way in self.ways: if way in program: - self._shell(self._expand(program, way)) + self._shell(program[way]) else: print("afo: warning: Unknown way `%s'" % str(way)) @@ -166,12 +155,6 @@ class AFO(object): try: raw_input() except: input() - def _expand(self, program, way): - macros = {} - for way in program: - macros['w%s' % way] = _Template(program[way]).safe_substitute(macros) - return _Template(program[way]).safe_substitute(macros) - @staticmethod def get_parameters_from_argv(argv=None): class MoreOptions(optparse.Option): -- 2.11.4.GIT