Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
### | |
# Read in XML as a stream, write out JSON as a stream. As little information | |
# is kept in memory as possible. | |
require 'nokogiri' | |
require 'psych' | |
class JSONTranslator < Nokogiri::XML::SAX::Document | |
attr_reader :emitter | |
def initialize emitter |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
namespace :symfony do | |
namespace :assets do | |
desc "Updates assets version" | |
task :update_version do | |
run "sed -i 's/\\(assets_version: \\)\\(.*\\)$/\\1 #{real_revision}/g' #{latest_release}/app/config/config.yml" | |
end | |
end | |
end | |
before "symfony:assetic:dump" do |
"""Generic linux daemon base class for python 3.x. | |
Source: http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/""" | |
import sys, os, time, atexit, signal, errno | |
class daemon: | |
"""A generic daemon class. | |
Usage: subclass the daemon class and override the run() method.""" |