<s> import os . path <EOL> from importlib import import_module <EOL> import collections <EOL> from django . conf import settings <EOL> from . utils import get_url <EOL> from waliki . rst2html5 import HTML5Writer <EOL> try : <EOL> from django . utils . module_loading import import_string <EOL> except ImportError : <EOL> from django . utils . module_loading import import_by_path as import_string <EOL> def _get_default_data_dir ( directory , abspath = True ) : <EOL> settings_mod = import_module ( settings . SETTINGS_MODULE ) <EOL> project_dir = os . path . dirname ( settings_mod . __name__ ) <EOL> if abspath : <EOL> project_dir = os . path . abspath ( project_dir ) <EOL> return os . path . join ( project_dir , directory ) <EOL> def deep_update ( d , u ) : <EOL> """<STR_LIT>""" <EOL> for k , v in u . items ( ) : <EOL> if isinstance ( v , collections . Mapping ) : <EOL> r = deep_update ( d . get ( k , { } ) , v ) <EOL> d [ k ] = r <EOL> else : <EOL> d [ k ] = u [ k ] <EOL> return d <EOL> def _get_markup_settings ( user_settings ) : <EOL> defaults = { '<STR_LIT>' : { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : <NUM_LIT:2> , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:5> , <EOL> } , <EOL> '<STR_LIT>' : HTML5Writer ( ) , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : { '<STR_LIT>' : get_url } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:2> } , <EOL> } <EOL> } <EOL> } <EOL> deep_update ( defaults , user_settings ) <EOL> return defaults <EOL> WALIKI_AVAILABLE_MARKUPS = getattr ( settings , '<STR_LIT>' , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> WALIKI_DEFAULT_MARKUP = WALIKI_AVAILABLE_MARKUPS [ <NUM_LIT:0> ] <EOL> WALIKI_SLUG_PATTERN = getattr ( settings , '<STR_LIT>' , '<STR_LIT>' ) <EOL> WALIKI_SLUGIFY_FUNCTION = getattr ( settings , '<STR_LIT>' , '<STR_LIT>' ) <EOL> WALIKI_SANITIZE_FUNCTION = getattr ( settings , '<STR_LIT>' , '<STR_LIT>' ) <EOL> get_slug = import_string ( WALIKI_SLUGIFY_FUNCTION ) <EOL> sanitize = import_string ( WALIKI_SANITIZE_FUNCTION ) <EOL> WALIKI_DATA_DIR = getattr ( settings , '<STR_LIT>' , None ) or _get_default_data_dir ( '<STR_LIT>' ) <EOL> WALIKI_INDEX_SLUG = getattr ( settings , '<STR_LIT>' , "<STR_LIT>" ) <EOL> WALIKI_MARKUPS_SETTINGS = _get_markup_settings ( getattr ( settings , '<STR_LIT>' , { } ) ) <EOL> WALIKI_PDF_INCLUDE_TITLE = getattr ( settings , '<STR_LIT>' , False ) <EOL> WALIKI_PDF_RST2PDF_BIN = getattr ( settings , '<STR_LIT>' , False ) <EOL> WALIKI_CODEMIRROR_SETTINGS = getattr ( settings , '<STR_LIT>' , <EOL> { '<STR_LIT>' : False , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : True , '<STR_LIT>' : True } ) <EOL> WALIKI_ANONYMOUS_USER_PERMISSIONS = getattr ( settings , '<STR_LIT>' , <EOL> ( '<STR_LIT>' , ) ) <EOL> WALIKI_LOGGED_USER_PERMISSIONS = getattr ( settings , '<STR_LIT>' , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> WALIKI_RENDER_403 = getattr ( settings , '<STR_LIT>' , True ) <EOL> WALIKI_PAGINATE_BY = getattr ( settings , '<STR_LIT>' , <NUM_LIT:20> ) <EOL> WALIKI_COMMITTER_EMAIL = getattr ( settings , '<STR_LIT>' , '<STR_LIT>' ) <EOL> WALIKI_COMMITTER_NAME = getattr ( settings , '<STR_LIT>' , '<STR_LIT>' ) <EOL> WALIKI_CACHE_TIMEOUT = getattr ( settings , '<STR_LIT>' , <NUM_LIT> * <NUM_LIT> * <NUM_LIT> ) <EOL> WALIKI_ATTACHMENTS_DIR = getattr ( settings , '<STR_LIT>' , None ) or _get_default_data_dir ( '<STR_LIT>' , False ) <EOL> WALIKI_UPLOAD_TO_PATTERN = '<STR_LIT>' <EOL> WALIKI_RST_DIRECTIVES = getattr ( settings , '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> WALIKI_RST_TRANSFORMS = getattr ( settings , '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> WALIKI_USE_MATHJAX = getattr ( settings , '<STR_LIT>' , False ) <EOL> WALIKI_BREADCRUMBS = getattr ( settings , '<STR_LIT>' , False ) <EOL> def WALIKI_UPLOAD_TO ( instance , filename ) : <EOL> return os . path . join ( WALIKI_ATTACHMENTS_DIR , <EOL> WALIKI_UPLOAD_TO_PATTERN % { '<STR_LIT>' : instance . page . slug , <EOL> '<STR_LIT>' : getattr ( instance . page , '<STR_LIT:id>' , '<STR_LIT>' ) , <EOL> '<STR_LIT:filename>' : filename , <EOL> '<STR_LIT>' : os . path . splitext ( filename ) [ <NUM_LIT:1> ] } ) <EOL> for mod in WALIKI_RST_DIRECTIVES : <EOL> register_directive = import_string ( mod + '<STR_LIT>' ) <EOL> register_directive ( ) </s>
