-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefaults.py
More file actions
29 lines (24 loc) · 878 Bytes
/
defaults.py
File metadata and controls
29 lines (24 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from hyde.fs import File
from hyde.plugin import CLTransformer
import subprocess
class DustPlugin(CLTransformer):
@property
def executable_name(self):
return 'dustc'
def begin_text_resource(self, resource, text):
if not resource.meta.dust:
return
source = File.make_temp(text.strip())
target = source
dust = self.app
args = [unicode(dust)]
args.append("--name=" + resource.source_file.name_without_extension)
args.append(unicode(source))
args.append(unicode(target))
try:
self.call_app(args)
except subprocess.CalledProcessError:
raise self.template.exception_class(
"Cannot process %s. Error occurred when "
"processing [%s]" % (self.name, resource.source_file))
return target.read_all()