<s> from gitology . config import settings as gsettings <EOL> from gitology . document import Document <EOL> from datetime import datetime <EOL> def create_blog ( blog , author , title , subtitle ) : <EOL> document = Document ( "<STR_LIT>" % blog ) <EOL> if not document . exists ( ) : <EOL> document . create ( <EOL> index_content = title , <EOL> format = "<STR_LIT:html>" , author = author , <EOL> ) <EOL> else : <EOL> document . set_raw_index ( title , "<STR_LIT:html>" ) <EOL> document . meta . author = author <EOL> document . meta . title = title <EOL> document . meta . subtitle = subtitle <EOL> document . meta . url = "<STR_LIT>" % blog <EOL> document . meta . type = "<STR_LIT>" <EOL> document . meta . save ( ) <EOL> blog_folder = gsettings . LOCAL_REPO_PATH . joinpath ( "<STR_LIT>" % blog ) <EOL> if not blog_folder . exists ( ) : blog_folder . makedirs ( ) <EOL> labels_folder = gsettings . LOCAL_REPO_PATH . joinpath ( "<STR_LIT>" % blog ) <EOL> if not labels_folder . exists ( ) : labels_folder . makedirs ( ) <EOL> def create_label ( blog , author , label_name , label_slug , label_description = None ) : <EOL> if label_description is None : <EOL> label_description = label_name <EOL> document = Document ( <EOL> "<STR_LIT>" % ( blog , label_slug ) <EOL> ) <EOL> if not document . exists ( ) : <EOL> document . create ( <EOL> index_content = label_name , <EOL> format = "<STR_LIT:html>" , author = author , <EOL> ) <EOL> else : <EOL> document . set_raw_index ( label_name , "<STR_LIT:html>" ) <EOL> document . meta . author = author <EOL> document . meta . title = label_name <EOL> document . meta . description = label_descrption <EOL> document . meta . slug = label_slug <EOL> document . meta . type = "<STR_LIT>" <EOL> document . meta . save ( ) <EOL> def blog_document ( document , url , blog = "<STR_LIT>" , dtime = None ) : <EOL> if not dtime : dtime = datetime . now ( ) <EOL> blog_file = gsettings . LOCAL_REPO_PATH . joinpath ( <EOL> "<STR_LIT>" <EOL> ) . joinpath ( blog ) . joinpath ( "<STR_LIT>" % dtime . year ) . joinpath ( <EOL> "<STR_LIT>" % dtime . month <EOL> ) . joinpath ( "<STR_LIT>" % dtime . day ) <EOL> if not blog_file . parent . exists ( ) : <EOL> blog_file . parent . makedirs ( ) <EOL> blog_file . open ( "<STR_LIT>" ) . write ( <EOL> "<STR_LIT>" % ( url , document . name , str ( dtime ) ) <EOL> ) <EOL> document . meta . url = url <EOL> document . meta . save ( ) <EOL> for label in document . meta . get ( "<STR_LIT>" , [ ] ) : <EOL> gsettings . LOCAL_REPO_PATH . joinpath ( <EOL> "<STR_LIT>" % ( blog , label ) <EOL> ) . open ( "<STR_LIT>" ) . write ( "<STR_LIT>" % url ) </s>
