mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 13:13:03 +00:00
adjustments to the import tool so binary plists can be read...
This commit is contained in:
parent
f1ce4866b6
commit
23bf5b7a1e
@ -103,7 +103,8 @@ class TmSnippet
|
||||
def initialize(file,info=nil)
|
||||
@file = file
|
||||
@info = info
|
||||
@snippet = Plist::parse_xml(file)
|
||||
@snippet = TmSnippet::read_plist(file)
|
||||
raise RuntimeError.new("Cannot convert this snippet #{file}!") unless @snippet;
|
||||
end
|
||||
|
||||
def name
|
||||
@ -177,12 +178,27 @@ class TmSnippet
|
||||
File.join(basedir,canonicalize(@file[0, @file.length-File.extname(@file).length]) + ".yasnippet")
|
||||
end
|
||||
|
||||
def self.read_plist(xml_or_binary)
|
||||
begin
|
||||
parsed = Plist::parse_xml(xml_or_binary)
|
||||
return parsed if parsed;
|
||||
raise RuntimeError.new "Probably in binary format and parse_xml is very quiet..."
|
||||
rescue RuntimeError => e
|
||||
if (system "plutil -convert xml1 '#{xml_or_binary}' -o /tmp/textmate_import")
|
||||
return Plist::parse_xml("/tmp/textmate_import")
|
||||
else
|
||||
raise RuntimeError.new "plutil failed miserably, check if you have it..."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
if $0 == __FILE__
|
||||
info_plist = Plist::parse_xml(Choice.choices.info_plist) if Choice.choices.info_plist
|
||||
if $0 == __FILE__
|
||||
|
||||
info_plist = TmSnippet::read_plist(Choice.choices.info_plist) if Choice.choices.info_plist;
|
||||
|
||||
if Choice.choices.output_dir
|
||||
FileUtils.mkdir_p Choice.choices.output_dir
|
||||
@ -217,7 +233,7 @@ if $0 == __FILE__
|
||||
puts "\n\n"
|
||||
end
|
||||
rescue Exception => e
|
||||
$stderr.puts "Oops... #{e.class}:#{e.message}"
|
||||
$stderr.puts "Oops... #{e.class}:#{e.message}\n#{e.backtrace.join("\n")}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user