diff options
| -rwxr-xr-x | examples/yaml-highlight/yaml_hl.py | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/examples/yaml-highlight/yaml_hl.py b/examples/yaml-highlight/yaml_hl.py index b6eb316..d6f7bf4 100755 --- a/examples/yaml-highlight/yaml_hl.py +++ b/examples/yaml-highlight/yaml_hl.py @@ -2,12 +2,6 @@ import yaml, codecs, sys, os.path, optparse -try: - unicode -except NameError: - unicode = str - - class Style: def __init__(self, header=None, footer=None, @@ -43,24 +37,17 @@ yaml.add_path_resolver(u'tag:yaml.org,2002:pairs', class YAMLHighlight: def __init__(self, options): - with open(options.config, 'rb') as yaml_file: - config = yaml.load(yaml_file.read()) + config = yaml.load(file(options.config, 'rb').read()) self.style = config[options.style] if options.input: - self.input = open(options.input, 'rb') + self.input = file(options.input, 'rb') else: self.input = sys.stdin if options.output: - self.output = open(options.output, 'wb') + self.output = file(options.output, 'wb') else: self.output = sys.stdout - def __del__(self): - if self.input not in (sys.stdin, None): - self.input.close() - if self.output not in (sys.stdout, None): - self.output.close() - def highlight(self): input = self.input.read() if input.startswith(codecs.BOM_UTF16_LE): |
