def load_settings():
    """
    Load zen coding's settings, combined with user-defined snippets
    """
    # First, check if the user even wants this to happen
    defaults = NSUserDefaults.standardUserDefaults()
    convert_to_zen = defaults.boolForKey_('TEAConvertUserSnippetsToZen')
    if convert_to_zen:
        orig_date = os.path.getmtime(plist_path)
        
        need_reload = globals()['_prev_settings'] is None
        
        # Does our cache path exist and is writable?
        cache_dir_exists = os.path.isdir(cache_folder)
        if not cache_dir_exists:
            # Attempt to create the cache folder
            try:
                os.makedirs(cache_folder, 0755)
                cache_dir_exists = True
            except os.error:
                NSLog('TEA Error: Cannot create zen coding cache path for user snippets')
        
        # In worst case scenario, we can't read or write to the cache file
        # so we'll need to read from preferences every time
        # This variable tracks the user snippets in case of that eventuality
        _data = None
        
        # check if cached file exists and up-to-date
        if cache_dir_exists and (not os.path.exists(cache_file) or \
           os.path.getmtime(cache_file) < orig_date):
            # need to reparse and cache data
            _data = _read_settings_from_app()
            try:
                fp = open(cache_file, 'wb')
                pickle.dump(_data, fp)
                fp.close()
            except IOError:
                NSLog('TEA Error: Zen user snippets cache file is not writable')
            need_reload = True
        
        if need_reload:
            try:
                fp = open(cache_file, 'rb')
                user_settings = pickle.load(fp)
                fp.close()
            except IOError:
                NSLog('TEA Error: Zen user snippets cache file is not readable')
                user_settings = _data
            globals()['_prev_settings'] = stparser.get_settings(user_settings)
            
        return globals()['_prev_settings']
    else:
        # They don't want to load in user snippets as zen snippets
        return stparser.get_settings()
def load_settings():
	"""
	Load zen coding's settings, combined with user-defined snippets
	"""
#	orig_date = os.path.getmtime(plist_path)
	
	need_reload = globals()['_prev_settings'] is None
	
	# check if cached file exists and up-to-date
#	if not os.path.exists(cache_file) or os.path.getmtime(cache_file) < orig_date:
#		# need to reparse and cache data
#		_data = _read_settings_from_app()
#		fp = open(cache_file, 'wb')
#		pickle.dump(_data, fp)
#		fp.close()
#		need_reload = True
		
	if need_reload:
#		fp = open(cache_file, 'rb')
#		user_settings = pickle.load(fp)
#		fp.close()
		globals()['_prev_settings'] = stparser.get_settings()
		
	return globals()['_prev_settings']
Beispiel #3
0
class ZenError(Exception):
    """
	Zen Coding specific error
	@since: 0.65
	"""
    def __init__(self, value):
        self.value = value

    def __str__(self):
        return repr(self.value)


# create default profiles
setup_profile('xhtml')
setup_profile('html', {'self_closing_tag': False})
setup_profile('xml', {
    'self_closing_tag': True,
    'tag_nl': True
})
setup_profile('plain', {
    'tag_nl': False,
    'indent': False,
    'place_cursor': False
})

# This method call explicity loads default settings from zen_settings.py on start up
# Comment this line if you want to load data from other resources (like editor's
# native snippet)
update_settings(stparser.get_settings())
Beispiel #4
0
			if not deepest_child.children:
				break
		
		return deepest_child
	
	def to_string(self):
		"@return {String}"
		content = ''.join([item.to_string() for item in self.children])
		return self.start + self.content + content + self.end
		
class ZenError(Exception):
	"""
	Zen Coding specific error
	@since: 0.65
	"""
	def __init__(self, value):
		self.value = value
	def __str__(self):
		return repr(self.value)
		
# create default profiles
setup_profile('xhtml');
setup_profile('html', {'self_closing_tag': False});
setup_profile('xml', {'self_closing_tag': True, 'tag_nl': True});
setup_profile('plain', {'tag_nl': False, 'indent': False, 'place_cursor': False});

# This method call explicity loads default settings from zen_settings.py on start up
# Comment this line if you want to load data from other resources (like editor's 
# native snippet) 
update_settings(stparser.get_settings())