signature stringlengths 8 3.44k | body stringlengths 0 1.41M | docstring stringlengths 1 122k | id stringlengths 5 17 |
|---|---|---|---|
@staticmethod<EOL><INDENT>def modify_init(uid, data_dic):<DEDENT> | postinfo = MPost.get_by_uid(uid)<EOL>entry = TabPost.update(<EOL>time_update=tools.timestamp(),<EOL>date=datetime.now(),<EOL>kind=data_dic['<STR_LIT>'] if '<STR_LIT>' in data_dic else postinfo.kind,<EOL>keywords=data_dic['<STR_LIT>'] if '<STR_LIT>' in data_dic else postinfo.keywords,<EOL>).where(TabPost.uid == uid)<EOL... | update when init. | f10019:c0:m36 |
@staticmethod<EOL><INDENT>def get_view_count(sig):<DEDENT> | try:<EOL><INDENT>return TabPost.get(uid=sig).view_count<EOL><DEDENT>except:<EOL><INDENT>return False<EOL><DEDENT> | get count of view. | f10019:c0:m37 |
@staticmethod<EOL><INDENT>def query_under_condition(condition, kind='<STR_LIT:2>'):<DEDENT> | if DB_CFG['<STR_LIT>'] == '<STR_LIT:s>':<EOL><INDENT>return TabPost.select().where(<EOL>(TabPost.kind == kind) & (TabPost.valid == <NUM_LIT:1>)<EOL>).order_by(<EOL>TabPost.time_update.desc()<EOL>)<EOL><DEDENT>return TabPost.select().where(<EOL>(TabPost.kind == kind) &<EOL>(TabPost.valid == <NUM_LIT:1>) &<EOL>TabPost.ex... | Get All data of certain kind according to the condition | f10019:c0:m46 |
@staticmethod<EOL><INDENT>def get_num_condition(con):<DEDENT> | return MPost.query_under_condition(con).count()<EOL> | Return the number under condition. | f10019:c0:m47 |
@staticmethod<EOL><INDENT>def query_list_pager(con, idx, kind='<STR_LIT:2>'):<DEDENT> | all_list = MPost.query_under_condition(con, kind=kind)<EOL>return all_list[(idx - <NUM_LIT:1>) * CMS_CFG['<STR_LIT>']: idx * CMS_CFG['<STR_LIT>']]<EOL> | Get records of certain pager. | f10019:c0:m49 |
@staticmethod<EOL><INDENT>def count_of_certain_kind(kind):<DEDENT> | recs = TabPost.select().where(TabPost.kind == kind)<EOL>return recs.count()<EOL> | Get the count of certain kind. | f10019:c0:m50 |
@staticmethod<EOL><INDENT>def total_number(kind):<DEDENT> | return TabPost.select().where(TabPost.kind == kind).count()<EOL> | Return the number of certian slug. | f10019:c0:m51 |
@staticmethod<EOL><INDENT>def query_pager_by_slug(kind, current_page_num=<NUM_LIT:1>):<DEDENT> | return TabPost.select().where(TabPost.kind == kind).order_by(<EOL>TabPost.time_create.desc()<EOL>).paginate(<EOL>current_page_num, CMS_CFG['<STR_LIT>']<EOL>)<EOL> | Query pager | f10019:c0:m52 |
@staticmethod<EOL><INDENT>def query_by_slug(slug):<DEDENT> | cat_rec = MCategory.get_by_slug(slug)<EOL>if cat_rec:<EOL><INDENT>cat_id = cat_rec.uid<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>if cat_id.endswith('<STR_LIT>'):<EOL><INDENT>cat_con = TabPost2Tag.par_id == cat_id<EOL><DEDENT>else:<EOL><INDENT>cat_con = TabPost2Tag.tag_id == cat_id<EOL><DEDENT>recs = TabPost... | 查询全部章节 | f10022:c0:m1 |
@staticmethod<EOL><INDENT>def query_all():<DEDENT> | recs = TabTag.select().where(TabTag.uid.endswith('<STR_LIT>')).order_by(TabTag.uid)<EOL>return recs<EOL> | 查询大类记录 | f10022:c0:m2 |
@staticmethod<EOL><INDENT>def create_reply(post_data):<DEDENT> | uid = tools.get_uuid()<EOL>TabReply.create(<EOL>uid=uid,<EOL>post_id=post_data['<STR_LIT>'],<EOL>user_name=post_data['<STR_LIT>'],<EOL>user_id=post_data['<STR_LIT>'],<EOL>timestamp=tools.timestamp(),<EOL>date=datetime.datetime.now(),<EOL>cnt_md=tornado.escape.xhtml_escape(post_data['<STR_LIT>']),<EOL>cnt_html=tools.mar... | Create the reply. | f10024:c0:m2 |
@staticmethod<EOL><INDENT>def query_by_post(postid):<DEDENT> | return TabReply.select().where(<EOL>TabReply.post_id == postid<EOL>).order_by(TabReply.timestamp.desc())<EOL> | Get reply list of certain post. | f10024:c0:m3 |
@staticmethod<EOL><INDENT>def count_of_certain():<DEDENT> | recs = TabReply.select()<EOL>return recs.count()<EOL> | Get the count of certain kind. | f10024:c0:m7 |
@staticmethod<EOL><INDENT>def total_number():<DEDENT> | return TabReply.select().count()<EOL> | Return the number. | f10024:c0:m8 |
@staticmethod<EOL><INDENT>def query_pager(current_page_num=<NUM_LIT:1>):<DEDENT> | return TabReply.select().paginate(current_page_num, CMS_CFG['<STR_LIT>'])<EOL> | Query pager | f10024:c0:m9 |
@staticmethod<EOL><INDENT>def query_by_post(postid):<DEDENT> | return TabUsage.select().where(<EOL>TabUsage.post_id == postid<EOL>)<EOL> | Query records by post. | f10025:c0:m0 |
@staticmethod<EOL><INDENT>def add_or_update(user_id, post_id, kind):<DEDENT> | rec = MUsage.query_by_signature(user_id, post_id)<EOL>cate_rec = MInfor2Catalog.get_first_category(post_id)<EOL>if cate_rec:<EOL><INDENT>cat_id = cate_rec.tag_id<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT>if rec.count() > <NUM_LIT:0>:<EOL><INDENT>logger.info('<STR_LIT>'.format(uid=post_id))<EOL>rec = rec.ge... | Create the record if new, else update it. | f10025:c0:m8 |
@staticmethod<EOL><INDENT>def query_all(limit=<NUM_LIT:20>):<DEDENT> | return TabEntity.select().limit(limit)<EOL> | Return the entities list. | f10026:c0:m1 |
@staticmethod<EOL><INDENT>def get_id_by_impath(path):<DEDENT> | logger.info('<STR_LIT>'.format(path))<EOL>entity_list = TabEntity.select().where(TabEntity.path == path)<EOL>out_val = None<EOL>if entity_list.count() == <NUM_LIT:1>:<EOL><INDENT>out_val = entity_list.get()<EOL><DEDENT>elif entity_list.count() > <NUM_LIT:1>:<EOL><INDENT>for rec in entity_list:<EOL><INDENT>MEntity.delet... | The the entity id by the path. | f10026:c0:m4 |
@staticmethod<EOL><INDENT>def create_entity(uid='<STR_LIT>', path='<STR_LIT>', desc='<STR_LIT>', kind='<STR_LIT:1>'):<DEDENT> | if path:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT>if uid:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>uid = get_uuid()<EOL><DEDENT>try:<EOL><INDENT>TabEntity.create(<EOL>uid=uid,<EOL>path=path,<EOL>desc=desc,<EOL>time_create=time.time(),<EOL>kind=kind<EOL>)<EOL>return True<EOL><DEDENT>... | create entity record in the database. | f10026:c0:m5 |
@staticmethod<EOL><INDENT>def get_last(postid):<DEDENT> | recs = TabWikiHist.select().where(<EOL>TabWikiHist.wiki_id == postid<EOL>).order_by(TabWikiHist.time_update.desc())<EOL>return None if recs.count() == <NUM_LIT:0> else recs.get()<EOL> | Get the last wiki in history. | f10027:c0:m0 |
@staticmethod<EOL><INDENT>def delete(uid):<DEDENT> | return MHelper.delete(TabWikiHist, uid)<EOL> | Delete by uid | f10027:c0:m1 |
@staticmethod<EOL><INDENT>def get_by_uid(uid):<DEDENT> | return MHelper.get_by_uid(TabPostHist, uid)<EOL> | return the record by uid | f10028:c0:m0 |
@staticmethod<EOL><INDENT>def delete(uid):<DEDENT> | del_count = TabPostHist.delete().where(TabPostHist.uid == uid)<EOL>try:<EOL><INDENT>del_count.execute()<EOL>return False<EOL><DEDENT>except:<EOL><INDENT>return True<EOL><DEDENT> | Delete by uid | f10028:c0:m1 |
@staticmethod<EOL><INDENT>def update_cnt(uid, post_data):<DEDENT> | entry = TabPostHist.update(<EOL>user_name=post_data['<STR_LIT>'],<EOL>cnt_md=tornado.escape.xhtml_escape(post_data['<STR_LIT>']),<EOL>time_update=tools.timestamp(),<EOL>).where(TabPostHist.uid == uid)<EOL>entry.execute()<EOL> | Update the content by ID. | f10028:c0:m2 |
@staticmethod<EOL><INDENT>def query_by_postid(postid, limit=<NUM_LIT:5>):<DEDENT> | recs = TabPostHist.select().where(<EOL>TabPostHist.post_id == postid<EOL>).order_by(<EOL>TabPostHist.time_update.desc()<EOL>).limit(limit)<EOL>return recs<EOL> | Query history of certian records. | f10028:c0:m3 |
@staticmethod<EOL><INDENT>def get_last(postid, limit=<NUM_LIT:10>):<DEDENT> | recs = TabPostHist.select().where(<EOL>TabPostHist.post_id == postid<EOL>).order_by(TabPostHist.time_update.desc()).limit(limit)<EOL>if recs.count():<EOL><INDENT>return recs.get()<EOL><DEDENT>return None<EOL> | Get the last one of the records. | f10028:c0:m4 |
@staticmethod<EOL><INDENT>def create_post_history(raw_data):<DEDENT> | uid = tools.get_uuid()<EOL>TabPostHist.create(<EOL>uid=uid,<EOL>title=raw_data.title,<EOL>post_id=raw_data.uid,<EOL>user_name=raw_data.user_name,<EOL>cnt_md=raw_data.cnt_md,<EOL>time_update=tools.timestamp(),<EOL>logo=raw_data.logo,<EOL>)<EOL>return True<EOL> | Create the history of certain post. | f10028:c0:m5 |
@staticmethod<EOL><INDENT>def get_rating(postid, userid):<DEDENT> | try:<EOL><INDENT>recs = TabRating.select().where(<EOL>(TabRating.post_id == postid) & (TabRating.user_id == userid)<EOL>)<EOL><DEDENT>except:<EOL><INDENT>return False<EOL><DEDENT>if recs.count() > <NUM_LIT:0>:<EOL><INDENT>return recs.get().rating<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT> | Get the rating of certain post and user. | f10029:c0:m2 |
@staticmethod<EOL><INDENT>def update(postid, userid, rating):<DEDENT> | rating_recs = TabRating.select().where(<EOL>(TabRating.post_id == postid) & (TabRating.user_id == userid)<EOL>)<EOL>if rating_recs.count() > <NUM_LIT:0>:<EOL><INDENT>MRating.__update_rating(rating_recs.get().uid, rating)<EOL><DEDENT>else:<EOL><INDENT>MRating.__insert_data(postid, userid, rating)<EOL><DEDENT> | Update the rating of certain post and user.
The record will be created if no record exists. | f10029:c0:m3 |
@staticmethod<EOL><INDENT>def __update_rating(uid, rating):<DEDENT> | entry = TabRating.update(<EOL>rating=rating<EOL>).where(TabRating.uid == uid)<EOL>entry.execute()<EOL> | Update rating. | f10029:c0:m4 |
@staticmethod<EOL><INDENT>def __insert_data(postid, userid, rating):<DEDENT> | uid = tools.get_uuid()<EOL>TabRating.create(<EOL>uid=uid,<EOL>post_id=postid,<EOL>user_id=userid,<EOL>rating=rating,<EOL>timestamp=tools.timestamp(),<EOL>)<EOL>return uid<EOL> | Inert new record. | f10029:c0:m5 |
@staticmethod<EOL><INDENT>def query_all():<DEDENT> | recs = TabPost2Tag.select(<EOL>TabPost2Tag,<EOL>TabTag.kind.alias('<STR_LIT>'),<EOL>).join(<EOL>TabTag,<EOL>on=(TabPost2Tag.tag_id == TabTag.uid)<EOL>)<EOL>return recs<EOL> | Query all the records from TabPost2Tag. | f10030:c0:m0 |
@staticmethod<EOL><INDENT>def remove_relation(post_id, tag_id):<DEDENT> | entry = TabPost2Tag.delete().where(<EOL>(TabPost2Tag.post_id == post_id) &<EOL>(TabPost2Tag.tag_id == tag_id)<EOL>)<EOL>entry.execute()<EOL>MCategory.update_count(tag_id)<EOL> | Delete the record of post 2 tag. | f10030:c0:m1 |
@staticmethod<EOL><INDENT>def remove_tag(tag_id):<DEDENT> | entry = TabPost2Tag.delete().where(<EOL>TabPost2Tag.tag_id == tag_id<EOL>)<EOL>entry.execute()<EOL> | Delete the records of certain tag. | f10030:c0:m2 |
@staticmethod<EOL><INDENT>def query_by_catid(catid):<DEDENT> | return TabPost2Tag.select().where(<EOL>TabPost2Tag.tag_id == catid<EOL>)<EOL> | Query the records by ID of catalog. | f10030:c0:m3 |
@staticmethod<EOL><INDENT>def query_by_post(postid):<DEDENT> | return TabPost2Tag.select().where(<EOL>TabPost2Tag.post_id == postid<EOL>).order_by(TabPost2Tag.order)<EOL> | Query records by post. | f10030:c0:m5 |
@staticmethod<EOL><INDENT>def __get_by_info(post_id, catalog_id):<DEDENT> | recs = TabPost2Tag.select().where(<EOL>(TabPost2Tag.post_id == post_id) &<EOL>(TabPost2Tag.tag_id == catalog_id)<EOL>)<EOL>if recs.count() == <NUM_LIT:1>:<EOL><INDENT>return recs.get()<EOL><DEDENT>elif recs.count() > <NUM_LIT:1>:<EOL><INDENT>out_rec = None<EOL>for rec in recs:<EOL><INDENT>if out_rec:<EOL><INDENT>entry ... | Geo the record by post and catalog. | f10030:c0:m6 |
@staticmethod<EOL><INDENT>def query_count():<DEDENT> | recs = TabPost2Tag.select(<EOL>TabPost2Tag.tag_id,<EOL>peewee.fn.COUNT(TabPost2Tag.tag_id).alias('<STR_LIT>')<EOL>).group_by(<EOL>TabPost2Tag.tag_id<EOL>)<EOL>return recs<EOL> | The count of post2tag. | f10030:c0:m7 |
@staticmethod<EOL><INDENT>def update_field(uid, post_id=None, tag_id=None, par_id=None):<DEDENT> | if post_id:<EOL><INDENT>entry = TabPost2Tag.update(<EOL>post_id=post_id<EOL>).where(TabPost2Tag.uid == uid)<EOL>entry.execute()<EOL><DEDENT>if tag_id:<EOL><INDENT>entry2 = TabPost2Tag.update(<EOL>par_id=tag_id[:<NUM_LIT:2>] + '<STR_LIT>',<EOL>tag_id=tag_id,<EOL>).where(TabPost2Tag.uid == uid)<EOL>entry2.execute()<EOL><... | Update the field of post2tag. | f10030:c0:m8 |
@staticmethod<EOL><INDENT>def add_record(post_id, catalog_id, order=<NUM_LIT:0>):<DEDENT> | rec = MPost2Catalog.__get_by_info(post_id, catalog_id)<EOL>if rec:<EOL><INDENT>entry = TabPost2Tag.update(<EOL>order=order,<EOL>par_id=rec.tag_id[:<NUM_LIT:2>] + '<STR_LIT>',<EOL>).where(TabPost2Tag.uid == rec.uid)<EOL>entry.execute()<EOL><DEDENT>else:<EOL><INDENT>TabPost2Tag.create(<EOL>uid=tools.get_uuid(),<EOL>par_i... | Create the record of post 2 tag, and update the count in g_tag. | f10030:c0:m9 |
@staticmethod<EOL><INDENT>def count_of_certain_category(cat_id, tag='<STR_LIT>'):<DEDENT> | if cat_id.endswith('<STR_LIT>'):<EOL><INDENT>cat_con = TabPost2Tag.par_id == cat_id<EOL><DEDENT>else:<EOL><INDENT>cat_con = TabPost2Tag.tag_id == cat_id<EOL><DEDENT>if tag:<EOL><INDENT>condition = {<EOL>'<STR_LIT>': [tag]<EOL>}<EOL>recs = TabPost2Tag.select().join(<EOL>TabPost,<EOL>on=((TabPost2Tag.post_id == TabPost.u... | Get the count of certain category. | f10030:c0:m10 |
@staticmethod<EOL><INDENT>def query_pager_by_slug(slug, current_page_num=<NUM_LIT:1>, tag='<STR_LIT>', order=False):<DEDENT> | cat_rec = MCategory.get_by_slug(slug)<EOL>if cat_rec:<EOL><INDENT>cat_id = cat_rec.uid<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>if cat_id.endswith('<STR_LIT>'):<EOL><INDENT>cat_con = TabPost2Tag.par_id == cat_id<EOL><DEDENT>else:<EOL><INDENT>cat_con = TabPost2Tag.tag_id == cat_id<EOL><DEDENT>if tag:<EOL><I... | Query pager via category slug. | f10030:c0:m11 |
@staticmethod<EOL><INDENT>def query_by_entity_uid(idd, kind='<STR_LIT>'):<DEDENT> | if kind == '<STR_LIT>':<EOL><INDENT>return TabPost2Tag.select(<EOL>TabPost2Tag,<EOL>TabTag.slug.alias('<STR_LIT>'),<EOL>TabTag.name.alias('<STR_LIT>')<EOL>).join(<EOL>TabTag, on=(TabPost2Tag.tag_id == TabTag.uid)<EOL>).where(<EOL>(TabPost2Tag.post_id == idd) &<EOL>(TabTag.kind != '<STR_LIT:z>')<EOL>).order_by(<EOL>TabP... | Query post2tag by certain post. | f10030:c0:m12 |
@staticmethod<EOL><INDENT>def query_by_id(idd):<DEDENT> | return MPost2Catalog.query_by_entity_uid(idd)<EOL> | Alias of `query_by_entity_uid`. | f10030:c0:m13 |
@staticmethod<EOL><INDENT>def get_first_category(app_uid):<DEDENT> | recs = MPost2Catalog.query_by_entity_uid(app_uid).objects()<EOL>if recs.count() > <NUM_LIT:0>:<EOL><INDENT>return recs.get()<EOL><DEDENT>return None<EOL> | Get the first, as the uniqe category of post. | f10030:c0:m14 |
@staticmethod<EOL><INDENT>def query_recent(user_id, num=<NUM_LIT:10>):<DEDENT> | return TabCollect.select(<EOL>TabCollect, TabPost.uid.alias('<STR_LIT>'),<EOL>TabPost.title.alias('<STR_LIT>'),<EOL>TabPost.view_count.alias('<STR_LIT>')<EOL>).where(<EOL>TabCollect.user_id == user_id<EOL>).join(<EOL>TabPost, on=(TabCollect.post_id == TabPost.uid)<EOL>).order_by(<EOL>TabCollect.timestamp.desc()<EOL>).l... | Collection of recent. | f10032:c0:m0 |
@staticmethod<EOL><INDENT>def get_by_signature(user_id, app_id):<DEDENT> | try:<EOL><INDENT>return TabCollect.get(<EOL>(TabCollect.user_id == user_id) &<EOL>(TabCollect.post_id == app_id)<EOL>)<EOL><DEDENT>except:<EOL><INDENT>return None<EOL><DEDENT> | Get the collection. | f10032:c0:m1 |
@staticmethod<EOL><INDENT>def count_of_user(user_id):<DEDENT> | return TabCollect.select(<EOL>TabCollect, TabPost.uid.alias('<STR_LIT>'),<EOL>TabPost.title.alias('<STR_LIT>'),<EOL>TabPost.view_count.alias('<STR_LIT>')<EOL>).where(<EOL>TabCollect.user_id == user_id<EOL>).join(<EOL>TabPost, on=(TabCollect.post_id == TabPost.uid)<EOL>).count()<EOL> | Get the cound of views. | f10032:c0:m2 |
@staticmethod<EOL><INDENT>def add_or_update(user_id, app_id):<DEDENT> | rec = MCollect.get_by_signature(user_id, app_id)<EOL>if rec:<EOL><INDENT>entry = TabCollect.update(<EOL>timestamp=int(time.time())<EOL>).where(TabCollect.uid == rec.uid)<EOL>entry.execute()<EOL><DEDENT>else:<EOL><INDENT>TabCollect.create(<EOL>uid=tools.get_uuid(),<EOL>user_id=user_id,<EOL>post_id=app_id,<EOL>timestamp=... | Add the collection or update. | f10032:c0:m4 |
def create_table(the_table): | try:<EOL><INDENT>the_table.create_table()<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT> | Create a certain table. | f10033:m0 |
def run_init_tables(*args): | print('<STR_LIT>')<EOL>create_table(TabPost)<EOL>create_table(TabTag)<EOL>create_table(TabMember)<EOL>create_table(TabWiki)<EOL>create_table(TabLink)<EOL>create_table(TabEntity)<EOL>create_table(TabPostHist)<EOL>create_table(TabWikiHist)<EOL>create_table(TabCollect)<EOL>create_table(TabPost2Tag)<EOL>create_table(TabRel... | Run to init tables. | f10033:m1 |
def drop_the_table(table_name): | try:<EOL><INDENT>table_name.drop_table()<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT> | Drop a table. | f10034:m0 |
def run_drop_tables(_): | print('<STR_LIT>')<EOL>drop_the_table(TabPost)<EOL>drop_the_table(TabTag)<EOL>drop_the_table(TabMember)<EOL>drop_the_table(TabWiki)<EOL>drop_the_table(TabLink)<EOL>drop_the_table(TabEntity)<EOL>drop_the_table(TabPostHist)<EOL>drop_the_table(TabWikiHist)<EOL>drop_the_table(TabCollect)<EOL>drop_the_table(TabPost2Tag)<EOL... | Running the script. | f10034:m1 |
def run_init(*args): | run_init_tables()<EOL>run_migrate()<EOL>run_gen_category()<EOL>run_create_admin()<EOL>run_auto()<EOL>run_whoosh()<EOL> | running init. | f10035:m0 |
def gen_post_map(file_name, ext_url='<STR_LIT>'): | with open(file_name, '<STR_LIT:a>') as fout:<EOL><INDENT>for kind_key in router_post:<EOL><INDENT>recent_posts = MPost.query_all(kind=kind_key, limit=<NUM_LIT>)<EOL>for recent_post in recent_posts:<EOL><INDENT>url = os.path.join(SITE_CFG['<STR_LIT>'],<EOL>router_post[recent_post.kind],<EOL>ext_url,<EOL>recent_post.uid)... | Generate the urls for posts.
:return: None | f10036:m0 |
def gen_wiki_map(file_name, ext_url='<STR_LIT>'): | <EOL>wiki_recs = MWiki.query_all(limit=<NUM_LIT>, kind='<STR_LIT:1>')<EOL>with open(file_name, '<STR_LIT:a>') as fileout:<EOL><INDENT>for rec in wiki_recs:<EOL><INDENT>url = os.path.join(SITE_CFG['<STR_LIT>'],<EOL>'<STR_LIT>' + '<STR_LIT>' if ext_url else '<STR_LIT>',<EOL>rec.title)<EOL>fileout.write('<STR_LIT>'.format... | Generate the urls for wiki.
:return: None | f10036:m1 |
def run_sitemap(_): | site_map_file = '<STR_LIT>'<EOL>if os.path.exists(site_map_file):<EOL><INDENT>os.remove(site_map_file)<EOL><DEDENT>gen_wiki_map(site_map_file)<EOL>gen_post_map(site_map_file)<EOL> | Generate the sitemap file.
:param args: args
:return: None | f10036:m2 |
def run_editmap(_): | edit_map_file = '<STR_LIT>'<EOL>if os.path.exists(edit_map_file):<EOL><INDENT>os.remove(edit_map_file)<EOL><DEDENT>gen_wiki_map(edit_map_file, ext_url='<STR_LIT>')<EOL>gen_post_map(edit_map_file, ext_url='<STR_LIT>')<EOL> | Generate the urls file for editing.
:param args: args
:return: None | f10036:m3 |
def build_directory(): | if os.path.exists('<STR_LIT>'):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>os.mkdir('<STR_LIT>')<EOL><DEDENT>if os.path.exists(WHOOSH_DB_DIR):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>os.makedirs(WHOOSH_DB_DIR)<EOL><DEDENT> | Build the directory for Whoosh database, and locale. | f10037:m0 |
def run_check_kind(_): | for kindv in router_post:<EOL><INDENT>for rec_cat in MCategory.query_all(kind=kindv):<EOL><INDENT>catid = rec_cat.uid<EOL>catinfo = MCategory.get_by_uid(catid)<EOL>for rec_post2tag in MPost2Catalog.query_by_catid(catid):<EOL><INDENT>postinfo = MPost.get_by_uid(rec_post2tag.post_id)<EOL>if postinfo.kind == catinfo.kind:... | Running the script. | f10037:m1 |
def run_create_admin(*args): | post_data = {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>}<EOL>if MUser.get_by_name(post_data['<STR_LIT>']):<EOL><INDENT>print('<STR_LIT>'.format(user_name='<STR_LIT>'))<EOL><DEDENT>else:<EOL><INDENT>MUser.create_user(post_data)<EOL><DEDEN... | creating the default administrator. | f10037:m2 |
def run_whoosh(*args): | running_whoosh.gen_whoosh_database(kind_arr=kind_arr, post_type=post_type)<EOL> | running whoosh | f10037:m3 |
def run_update_cat(_): | recs = MPost2Catalog.query_all().objects()<EOL>for rec in recs:<EOL><INDENT>if rec.tag_kind != '<STR_LIT:z>':<EOL><INDENT>print('<STR_LIT:->' * <NUM_LIT>)<EOL>print(rec.uid)<EOL>print(rec.tag_id)<EOL>print(rec.par_id)<EOL>MPost2Catalog.update_field(rec.uid, par_id=rec.tag_id[:<NUM_LIT:2>] + "<STR_LIT>")<EOL><DEDENT><DE... | Update the catagery. | f10037:m4 |
def entry(argv): | command_dic = {<EOL>'<STR_LIT>': run_migrate,<EOL>'<STR_LIT>': run_init,<EOL>'<STR_LIT>': run_send_nologin,<EOL>'<STR_LIT>': run_send_all,<EOL>'<STR_LIT>': run_review,<EOL>'<STR_LIT>': run_sitemap,<EOL>'<STR_LIT>': run_editmap,<EOL>'<STR_LIT>': run_check_kind,<EOL>'<STR_LIT>': run_init_tables,<EOL>'<STR_LIT>': run_drop... | Command entry | f10038:m0 |
def __get_diff_recent(): | diff_str = '<STR_LIT>'<EOL>for key in router_post:<EOL><INDENT>recent_posts = MPost.query_recent_edited(tools.timestamp() - TIME_LIMIT, kind=key)<EOL>for recent_post in recent_posts:<EOL><INDENT>hist_rec = MPostHist.get_last(recent_post.uid)<EOL>if hist_rec:<EOL><INDENT>raw_title = hist_rec.title<EOL>new_title = recent... | Generate the difference of posts. recently. | f10039:m0 |
def __get_wiki_review(email_cnt, idx): | recent_posts = MWiki.query_recent_edited(tools.timestamp() - TIME_LIMIT, kind='<STR_LIT:2>')<EOL>for recent_post in recent_posts:<EOL><INDENT>hist_rec = MWikiHist.get_last(recent_post.uid)<EOL>if hist_rec:<EOL><INDENT>foo_str = '''<STR_LIT>'''.format(idx, recent_post.user_name, recent_post.title,<EOL>os.path.join(SITE_... | Review for wikis. | f10039:m1 |
def __get_page_review(email_cnt, idx): | recent_posts = MWiki.query_recent_edited(tools.timestamp() - TIME_LIMIT)<EOL>for recent_post in recent_posts:<EOL><INDENT>hist_rec = MWikiHist.get_last(recent_post.uid)<EOL>if hist_rec:<EOL><INDENT>foo_str = '''<STR_LIT>'''.format(idx, recent_post.user_name, recent_post.title,<EOL>os.path.join(SITE_CFG['<STR_LIT>'], '<... | Review for pages. | f10039:m2 |
def __get_post_review(email_cnt, idx): | for key in router_post:<EOL><INDENT>recent_posts = MPost.query_recent_edited(tools.timestamp() - TIME_LIMIT, kind=key)<EOL>for recent_post in recent_posts:<EOL><INDENT>hist_rec = MPostHist.get_last(recent_post.uid)<EOL>if hist_rec:<EOL><INDENT>foo_str = '''<STR_LIT>'''.format(idx, recent_post.user_name, recent_post.tit... | Review for posts. | f10039:m3 |
def run_review(*args): | email_cnt = '''<STR_LIT>'''<EOL>idx = <NUM_LIT:1><EOL>email_cnt = email_cnt + '<STR_LIT>'<EOL>email_cnt, idx = __get_post_review(email_cnt, idx) <EOL>email_cnt, idx = __get_page_review(email_cnt, idx) <EOL>email_cnt, idx = __get_wiki_review(email_cnt, idx) <EOL>diff_str = __get_diff_recent()<EOL>if len(diff_str) < <... | Get the difference of recents modification, and send the Email.
For: wiki, page, and post. | f10039:m4 |
def run_check200(_): | tstr = '<STR_LIT>'<EOL>idx = <NUM_LIT:1><EOL>for kind in config.router_post.keys():<EOL><INDENT>posts = MPost.query_all(kind=kind, limit=<NUM_LIT>)<EOL>for post in posts:<EOL><INDENT>the_url0 = '<STR_LIT>'.format(<EOL>site_url=config.SITE_CFG['<STR_LIT>'],<EOL>kind_url=config.router_post[post.kind],<EOL>uid=post.uid)<E... | Running the script. | f10040:m0 |
def gen_xlsx_category(): | if os.path.exists(XLSX_FILE):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>return<EOL><DEDENT>order_index = <NUM_LIT:1><EOL>all_cate_arr = []<EOL>for sheet_ranges in load_workbook(filename=XLSX_FILE):<EOL><INDENT>kind_sig = str(sheet_ranges['<STR_LIT>'].value).strip()<EOL>for row_num in range(<NUM_LIT:3>, <NUM_LIT>):... | Genereting catetory from xlsx file. | f10042:m0 |
def gen_category(yaml_file, sig): | out_dic = yaml.load(open(yaml_file))<EOL>for key in out_dic:<EOL><INDENT>if key.endswith('<STR_LIT>'):<EOL><INDENT>uid = key[<NUM_LIT:1>:]<EOL>cur_dic = out_dic[key]<EOL>porder = cur_dic['<STR_LIT>']<EOL>cat_dic = {<EOL>'<STR_LIT>': uid,<EOL>'<STR_LIT>': cur_dic['<STR_LIT>'],<EOL>'<STR_LIT:name>': cur_dic['<STR_LIT:nam... | Genereting catetory from YAML file. | f10042:m1 |
def gen_yaml_category(): | for wroot, _, wfiles in os.walk('<STR_LIT>'):<EOL><INDENT>for wfile in wfiles:<EOL><INDENT>if wfile.endswith('<STR_LIT>'):<EOL><INDENT>gen_category(os.path.join(wroot, wfile), wfile[<NUM_LIT:0>])<EOL><DEDENT><DEDENT><DEDENT> | find YAML. | f10042:m2 |
def run_gen_category(*args): | gen_yaml_category()<EOL>gen_xlsx_category()<EOL> | to run | f10042:m3 |
def build_dir(): | tag_arr = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT:list>', '<STR_LIT>']<EOL>path_arr = [os.path.join(CRUD_PATH, x) for x in tag_arr]<EOL>for wpath in path_arr:<EOL><INDENT>if os.path.exists(wpath):<EOL><INDENT>continue<EOL><DEDENT>os.makedirs(wpath)<EOL><DEDENT> | Build the directory used for templates. | f10043:m0 |
def __write_filter_dic(wk_sheet, column): | row1_val = wk_sheet['<STR_LIT>'.format(column)].value<EOL>row2_val = wk_sheet['<STR_LIT>'.format(column)].value<EOL>if row1_val and row1_val.strip() != '<STR_LIT>':<EOL><INDENT>row2_val = row2_val.strip()<EOL>slug_name, c_name = [x.strip() for x in row1_val.strip().split('<STR_LIT:U+002C>')]<EOL>tags1 = [x.strip() for ... | return filter dic for certain column | f10044:m0 |
def gen_html_dic(): | if WORK_BOOK:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT>html_dics = {}<EOL>for wk_sheet in WORK_BOOK:<EOL><INDENT>for column in FILTER_COLUMNS:<EOL><INDENT>kkey, kval = __write_filter_dic(wk_sheet, column)<EOL>if kkey:<EOL><INDENT>html_dics[kkey] = kval<EOL><DEDENT><DEDENT><DEDENT>return h... | 生成 Filter . | f10044:m1 |
def gen_array_crud(): | if WORK_BOOK:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT>papa_id = <NUM_LIT:0><EOL>switch_dics = {}<EOL>kind_dics = {}<EOL>for work_sheet in WORK_BOOK:<EOL><INDENT>kind_sig = str(work_sheet['<STR_LIT>'].value).strip()<EOL>for row_num in range(<NUM_LIT:3>, <NUM_LIT:1000>):<EOL><INDENT>a_cell... | Return the dictionay of the switcher form XLXS file.
if valud of the column of the row is `1`, it will be added to the array. | f10044:m2 |
def __get_switch_arr(work_sheet, row_num): | u_dic = []<EOL>for col_idx in FILTER_COLUMNS:<EOL><INDENT>cell_val = work_sheet['<STR_LIT>'.format(col_idx, row_num)].value<EOL>if cell_val in [<NUM_LIT:1>, '<STR_LIT:1>']:<EOL><INDENT>u_dic.append(work_sheet['<STR_LIT>'.format(col_idx)].value.strip().split('<STR_LIT:U+002C>')[<NUM_LIT:0>])<EOL><DEDENT><DEDENT>return u... | if valud of the column of the row is `1`, it will be added to the array. | f10044:m3 |
def gen_input_add(sig_dic): | if sig_dic['<STR_LIT>'] == '<STR_LIT>':<EOL><INDENT>html_str = HTML_TPL_DICT['<STR_LIT>'].format(<EOL>sig_en=sig_dic['<STR_LIT>'],<EOL>sig_zh=sig_dic['<STR_LIT>'],<EOL>sig_dic=sig_dic['<STR_LIT>'][<NUM_LIT:1>],<EOL>sig_type=sig_dic['<STR_LIT:type>']<EOL>)<EOL><DEDENT>else:<EOL><INDENT>html_str = HTML_TPL_DICT['<STR_LIT... | Adding for HTML Input control. | f10045:m0 |
def gen_input_edit(sig_dic): | if sig_dic['<STR_LIT>'] == '<STR_LIT>':<EOL><INDENT>html_str = HTML_TPL_DICT['<STR_LIT>'].format(<EOL>sig_en=sig_dic['<STR_LIT>'],<EOL>sig_zh=sig_dic['<STR_LIT>'],<EOL>sig_dic=sig_dic['<STR_LIT>'][<NUM_LIT:1>],<EOL>sig_type=sig_dic['<STR_LIT:type>']<EOL>)<EOL><DEDENT>else:<EOL><INDENT>html_str = HTML_TPL_DICT['<STR_LIT... | Editing for HTML input control. | f10045:m1 |
def gen_input_view(sig_dic): | if sig_dic['<STR_LIT>'] == '<STR_LIT>':<EOL><INDENT>html_str = HTML_TPL_DICT['<STR_LIT>'].format(<EOL>sig_zh=sig_dic['<STR_LIT>'],<EOL>sig_unit=sig_dic['<STR_LIT>'][<NUM_LIT:1>]<EOL>)<EOL><DEDENT>elif sig_dic['<STR_LIT>'] in ['<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>']:<EOL><IN... | Viewing the HTML text. | f10045:m2 |
def gen_radio_add(sig_dic): | <EOL>radio_control_str = '<STR_LIT>'<EOL>dic_tmp = sig_dic['<STR_LIT>']<EOL>for key, val in dic_tmp.items():<EOL><INDENT>tmp_str = '''<STR_LIT>'''.format(sig_dic['<STR_LIT>'], key, val)<EOL>radio_control_str += tmp_str<EOL><DEDENT>return '''<STR_LIT>'''.format(<EOL>sig_en=sig_dic['<STR_LIT>'],<EOL>sig_zh=sig_dic['<STR_... | Adding for HTML radio control. | f10045:m3 |
def gen_radio_edit(sig_dic): | edit_zuoxiang = '''<STR_LIT>'''.format(sig_dic['<STR_LIT>'], sig_dic['<STR_LIT>'])<EOL>dic_tmp = sig_dic['<STR_LIT>']<EOL>for key in dic_tmp.keys():<EOL><INDENT>tmp_str = '''<STR_LIT>'''.format(sig_dic['<STR_LIT>'], key, dic_tmp[key])<EOL>edit_zuoxiang += tmp_str<EOL><DEDENT>edit_zuoxiang += '''<STR_LIT>'''<EOL>return ... | editing for HTML radio control. | f10045:m4 |
def gen_radio_view(sig_dic): | view_zuoxiang = '''<STR_LIT>'''.format(sig_dic['<STR_LIT>'])<EOL>dic_tmp = sig_dic['<STR_LIT>']<EOL>for key in dic_tmp.keys():<EOL><INDENT>tmp_str = '''<STR_LIT>'''.format(sig_dic['<STR_LIT>'], key, dic_tmp[key])<EOL>view_zuoxiang += tmp_str<EOL><DEDENT>view_zuoxiang += '''<STR_LIT>'''<EOL>return view_zuoxiang<EOL> | for checkbox | f10045:m5 |
def gen_checkbox_add(sig_dic): | html_wuneisheshi = '''<STR_LIT>'''.format(sig_dic['<STR_LIT>'], sig_dic['<STR_LIT>'])<EOL>dic_tmp = sig_dic['<STR_LIT>']<EOL>for key in dic_tmp.keys():<EOL><INDENT>tmp_str = '''<STR_LIT>'''.format(sig_dic['<STR_LIT>'], key, dic_tmp[key])<EOL>html_wuneisheshi += tmp_str<EOL><DEDENT>html_wuneisheshi += '''<STR_LIT>'''<EO... | for checkbox | f10045:m6 |
def gen_checkbox_edit(sig_dic): | edit_wuneisheshi = '''<STR_LIT>'''.format(sig_dic['<STR_LIT>'], sig_dic['<STR_LIT>'])<EOL>dic_tmp = sig_dic['<STR_LIT>']<EOL>for key in dic_tmp.keys():<EOL><INDENT>tmp_str = '''<STR_LIT>'''.format(sig_dic['<STR_LIT>'], key, dic_tmp[key])<EOL>edit_wuneisheshi += tmp_str<EOL><DEDENT>edit_wuneisheshi += '''<STR_LIT>'''<EO... | for checkbox | f10045:m7 |
def gen_checkbox_view(sig_dic): | view_zuoxiang = '''<STR_LIT>'''.format(sig_dic['<STR_LIT>'])<EOL>dic_tmp = sig_dic['<STR_LIT>']<EOL>for key in dic_tmp.keys():<EOL><INDENT>tmp_str = '''<STR_LIT>'''.format(key, sig_dic['<STR_LIT>'], dic_tmp[key])<EOL>view_zuoxiang += tmp_str<EOL><DEDENT>view_zuoxiang += '''<STR_LIT>'''<EOL>return view_zuoxiang<EOL> | for checkbox | f10045:m8 |
def gen_select_add(sig_dic): | option_str = '<STR_LIT>'<EOL>for key, val in sig_dic['<STR_LIT>'].items():<EOL><INDENT>tmp_str = '''<STR_LIT>'''.format(key, val)<EOL>option_str += tmp_str<EOL><DEDENT>return '''<STR_LIT>'''.format(sig_en=sig_dic['<STR_LIT>'], sig_zh=sig_dic['<STR_LIT>'], option_str=option_str)<EOL> | Adding for select control.
:param sig_dic:
html_media_type = {
'en': 'tag_media_type',
'zh': 'Media_type',
'dic': {1: 'Document', 2: 'Data', 3: 'Program'},
'type': 'select',
} | f10045:m9 |
def gen_select_edit(sig_dic): | option_str = '<STR_LIT>'<EOL>for key, val in sig_dic['<STR_LIT>'].items():<EOL><INDENT>tmp_str = '''<STR_LIT>'''.format(sig_dic['<STR_LIT>'], key, val)<EOL>option_str += tmp_str<EOL><DEDENT>return '''<STR_LIT>'''.format(sig_en=sig_dic['<STR_LIT>'], sig_zh=sig_dic['<STR_LIT>'], option_str=option_str)<EOL> | Editing for select control. | f10045:m10 |
def gen_select_view(sig_dic): | option_str = '<STR_LIT>'<EOL>dic_tmp = sig_dic['<STR_LIT>']<EOL>for key, val in dic_tmp.items():<EOL><INDENT>tmp_str = '''<STR_LIT>'''.format(sig_en=sig_dic['<STR_LIT>'], sig_key=key, sig_dic=val)<EOL>option_str += tmp_str<EOL><DEDENT>return '''<STR_LIT>'''.format(sig_zh=sig_dic['<STR_LIT>'], option_str=option_str)<EOL... | HTML view, for selection. | f10045:m11 |
def gen_file_add(sig_dic): | _ = sig_dic<EOL>add_html = '''<STR_LIT>'''<EOL>return add_html<EOL> | For adding file | f10045:m12 |
def gen_file_view(sig_dic): | _ = sig_dic<EOL>view_html = '<STR_LIT>'<EOL>return view_html<EOL> | for file viewing. | f10045:m13 |
def gen_file_edit(sig_dic): | _ = sig_dic<EOL>view_html = '''<STR_LIT>'''<EOL>return view_html<EOL> | for editing file. | f10045:m14 |
def gen_input_list(sig_dic): | out_str = '''<STR_LIT>'''.format(sig_dic['<STR_LIT>'], sig_dic['<STR_LIT>'], sig_dic['<STR_LIT>'][<NUM_LIT:1>])<EOL>return out_str<EOL> | For generating List view HTML file for INPUT.
for each item. | f10045:m15 |
def gen_radio_list(sig_dic): | view_zuoxiang = '''<STR_LIT>'''<EOL>dic_tmp = sig_dic['<STR_LIT>']<EOL>for key in dic_tmp.keys():<EOL><INDENT>tmp_str = '''<STR_LIT>'''.format(sig_dic['<STR_LIT>'], key, dic_tmp[key])<EOL>view_zuoxiang += tmp_str<EOL><DEDENT>view_zuoxiang += '''<STR_LIT>'''<EOL>return view_zuoxiang<EOL> | For generating List view HTML file for RADIO.
for each item. | f10045:m16 |
def gen_checkbox_list(sig_dic): | view_zuoxiang = '''<STR_LIT>'''<EOL>dic_tmp = sig_dic['<STR_LIT>']<EOL>for key in dic_tmp.keys():<EOL><INDENT>tmp_str = '''<STR_LIT>'''.format(key, sig_dic['<STR_LIT>'], dic_tmp[key])<EOL>view_zuoxiang += tmp_str<EOL><DEDENT>view_zuoxiang += '''<STR_LIT>'''<EOL>return view_zuoxiang<EOL> | For generating List view HTML file for CHECKBOX.
for each item. | f10045:m17 |
def gen_select_list(sig_dic): | view_jushi = '''<STR_LIT>'''<EOL>dic_tmp = sig_dic['<STR_LIT>']<EOL>for key in dic_tmp.keys():<EOL><INDENT>tmp_str = '''<STR_LIT>'''.format(sig_dic['<STR_LIT>'], key, dic_tmp[key])<EOL>view_jushi += tmp_str<EOL><DEDENT>view_jushi += '''<STR_LIT>'''<EOL>return view_jushi<EOL> | For generating List view HTML file for SELECT.
for each item. | f10045:m18 |
def minify(the_str): | return the_str<EOL> | Redefine the function for it is htmlmin.
For it not work fine for Tornado template. | f10046:m0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.