当前位置: 首页 > news >正文

门户网站布局wordpress调用指定分类的文章

门户网站布局,wordpress调用指定分类的文章,网页设计学徒培训招生,网站专题页是什么这次补充了好几个函数#xff0c;并且新加了date_sub函数#xff0c;代码写的比较随意#xff0c;有的地方比较繁琐#xff0c;还待改进#xff0c;而且这种文本处理的东西#xff0c;经常需要补充先前没考虑到的情况#xff0c;要经常修改。估计下一篇就可以补充完所有…这次补充了好几个函数并且新加了date_sub函数代码写的比较随意有的地方比较繁琐还待改进而且这种文本处理的东西经常需要补充先前没考虑到的情况要经常修改。估计下一篇就可以补充完所有代码。 import re import os import tkinter.filedialog from tkinter import *class Hive2Presto:def __int__(self):self.t_funcs [substr, nvl, substring, unix_timestamp] \[to_date, concat, sum, avg, abs, year, month, ceiling, floor]self.time_funcs [date_add, datediff, add_months, date_sub]self.funcs self.t_funcs self.time_funcsself.current_path os.path.abspath(__file__)self.dir os.path.dirname(self.current_path)self.result []self.error []self.filename def main(self):self.root Tk()self.root.config(bg#ff741d) # 背景颜色设置为公司主题色^_^self.root.title(Hive转Presto)self.win_width 550self.win_height 500self.screen_width self.root.winfo_screenwidth()self.screen_height self.root.winfo_screenheight()self.x (self.screen_width - self.win_width) // 2self.y (self.screen_height - self.win_height) // 2self.root.geometry(f{self.win_width}x{self.win_height}{self.x}{self.y})font (楷体, 11)self.button Button(self.root, text转换, commandself.trans, bg#ffcc8c, fontfont, anchore)self.button.grid(row0, column0, padx100, pady10, stickyW)self.file_button Button(self.root, text选择文件, commandself.choose_file, bg#ffcc8c, fontfont,anchore)self.file_button.grid(row0, column1, padx0, pady10, stickyW)self.entry Entry(self.root, width65, fontfont)self.entry.insert(0, 输入Hive代码)self.entry.grid(row1, column0, padx10, pady10, columnspan2)self.entry.bind(Button-1, self.delete_text)self.text Text(self.root, width75, height20)self.text.grid(row2, column0, padx10, pady10, columnspan2)self.des_label Label(self.root, text可以复制结果也有生成的文件与选取的文件同文件夹, bg#ffcc8c,font(楷体, 10))self.des_label.grid(row3, column0, padx10, pady10, columnspan2)s for i in range(0, (n : len(self.funcs)), 4):if i 4 n:s ,.join(self.funcs[i:i 4]) \nelse:s ,.join(self.funcs[i:]) \ns s[:-1]self.des_label1 Label(self.root, texts, bg#ffcc8c,font(楷体, 10))self.des_label1.grid(row4, column0, padx10, pady10, columnspan2)self.root.columnconfigure(0, minsize10)self.root.columnconfigure(1, minsize10)self.root.columnconfigure(0, pad5)self.root.mainloop()def replace_func(self, s, res):把搜索到函数整体取出来处理括号中的参数:param s::param res::return:for f in res:f1 f.replace(\n, ).strip()f1 re.sub(r(\s*), (, f1)# 搜索括号里的字符串if re.findall(r(\w*)\(, f1):func_name re.findall(r(\w*)\(, f1)[0].strip()else:continuetry:if date_add func_name.lower():date, date_num self.extact_func(f1, func_name)s_n fdate_add(day,{date_num},cast(substr(cast{date} as varchar,1,10) as date))s s.replace(f, s_n)elif datediff func_name.lower():date1, date2 self.extact_func(f1, func_name)s_n fdate_add(day,{date2},cast(substr(cast{date} as varchar,1,10) as date),cast(substr(cast{date1} as varchar),1,10) as date))s s.replace(f, s_n)elif nvl func_name.lower():s1, s2 self.extact_func(f1, func_name)s_n fcoalesce({s1},{s2})s s.replace(f, s_n)elif substr func_name.lower():date, start, end self.extact_func(f1, func_name)s_n fsubstr(cast({date} as varchar),{start},{end}s s.replace(f, s_n)elif substring func_name.lower():date, start, end self.extact_func(f1, func_name)s_n fsubstring(cast({date} as varchar),{start},{end}s s.replace(f, s_n)elif unit_timestamp func_name.lower():date self.extact_func(f1, func_name)[0]s_n fto_unixtime(cast({date} as timestanp))s s.replace(f, s_n)elif to_date func_name.lower():date self.extact_func(f1, func_name)[0]s_n fcast({date} as date)s s.replace(f, s_n)elif concat func_name.lower():res self.extact_func(f1, func_name)[0]s_n fconcat(for r in res:r r.strip().replace(\n, )s_n fcast({r} as varchar),s_n s_n[:-1] )s s.replace(f, s_n)elif sum func_name.lower():if unix_timestamp in f1 or to_unixtime in f1:continuess self.extact_func(f1, func_name)[0]if if( in ss.replace( , ):continues self.func_trans(f, f1, func_name, ss, s)elif avg func_name.lower():if unix_timestamp in f1 or to_unixtime in f1:continuess self.extact_func(f1, func_name)[0]if if( in ss.replace( , ):continues self.func_trans(f, f1, func_name, ss, s)elif abs func_name.lower():if unix_timestamp in f1 or to_unixtime in f1:continuess self.extact_func(f1, func_name)[0]if if( in ss.replace( , ):continues self.func_trans(f, f1, func_name, ss, s)elif ceiling func_name.lower():if unix_timestamp in f1 or to_unixtime in f1:continuess self.extact_func(f1, func_name)[0]if if( in ss.replace( , ):continues self.func_trans(f, f1, func_name, ss, s)elif floor func_name.lower():if unix_timestamp in f1 or to_unixtime in f1:continuess self.extact_func(f1, func_name)[0]if if( in ss.replace( , ):continues self.func_trans(f, f1, func_name, ss, s)elif year func_name.lower():date self.extact_func(f1, func_name)[0]s_n fyear(cast(substr(cast({date} as varchar,1,10) as date))s s.replace(f, s_n)elif month func_name.lower():date self.extact_func(f1, func_name)[0]s_n fmonth(cast(substr(cast({date} as varchar,1,10) as date))s s.replace(f, s_n)elif date_sub func_name.lower():date, date_num self.extact_func(f1, func_name)s_n fdate_add(day,-{date_num},cast(substr(cast{date} as varchar,1,10) as date))s s.replace(f, s_n)except:self.error.append(f源代码中{func_name}函数参数输入可能有错误具体为{f1})continueif self.error:self.entry.delete(0, END)self.text.delete(1.0, END)self.text.insert(end, f{s})self.error.insert(0, 转换失败有部分没有转成功\n)root_ex Tk()root_ex.title(错误)win_width 600win_height 200screen_width root_ex.winfo_screenwidth()screen_height root_ex.winfo_screenheight()x (screen_width - win_width) // 2y (screen_height - win_height) // 2root_ex.geometry(f{win_width}x{win_height}{x}{y})label_ex Label(root_ex, text\n.join(self.error), font(楷体, 10))label_ex.pack()root_ex.mainloop()return sdef func_trans(self, f, f1, func_name, ss, s):if not ( in ss or - in ss or * in ss or / in ss):date self.extact_func(f1, func_name)[0]s_n f{func_name}(cast{date} as double))s s.replace(f, s_n)else:res1 self.mysplit(f1)s_n fn len(s_n)for item in res1:if any(c.isalpha() for c in item.replace( , )):idxs s_n.find(item)idxs [idxs] if type(idxs) ! list else idxsfor idx in idxs:if idx len(item) 3 n:if not as in s_n[idx:idx len(item) 4]:s_n re.sub(rf\b{item}\b, fcast({item} as double), s_n)else:s_n re.sub(rf\b{item}\b, fcast({item} as double), s_n)s s.replace(f, s_n)return sdef choose_file(self):如果代码太多从text中输入会很卡直接选择代码文件输入会很快:return:self.filename tkinter.filedialog.askopenfilename()if / in self.filename:self.filename self.filename.replace(/, \\)self.entry.delete(0, END)self.entry.insert(0, self.filename)def findvar(self, ss):搜索与计算有关的字段:param ss::return:global r1b [, -, *, /, , !, , , , , ]result1 []result2 []result1_n []result2_n []res_ops []res1_ops []res_adj []res1_adj []for op in b:s_temp1 ss.replace(\n, )s_temp2 ss.replace(\n, )s_temp3 ss.replace(\n, )if op / or op :op opelif op or op - or op * or op or op :op f\\{op[0]}else:op f\\{op[0]}\\{op[1]}parttern f\s*-*\d\s*{op}\s*\w| f\s*-*\d\.\s*{op}\s*\w\.\s*\w| \ f\s*\w\.\s*\w\s*{op}\s*\w\.\s*\w| f\s*\w\s*{op}\s*\w\.\s*\w| \ f\s*\w\.\s*\w\s*{op}\s*\w| f\s*\w\s*{op}\s*\wparttern1 f\s*\)\s*{op}\s*\w| f\s*\)\s*{op}\s*\w\.\s*\w| \ f\s*\w\s*{op}\s*\(| ff\s*\w\.\s*{op}\s*\(parttern2 f\s*\w\s*{op}\s*\w| f\s*\w\s*{op}\s*\w\.\s*\w| \ f\s*\w\s*{op}\s*\w| ff\s*\w\.\s*{op}\s*\wwhile True:res re.findall(parttern, s_temp1)if not res:breakresult2.extend(res)for r in res:r1 r.replace( , ).split(fop)result1.append(r1)res_ops.append(f{op})res_adj.append(False)s_temp1 s_temp1.replace(f{r1[0]}, )# 搜索带括号的计算if op or op - or op * or op /:while True:res re.findall(parttern1, s_temp2)if not res:breakresult2.extend(res)for r in res:r1 r.replace( , ).split(f{op})result1.append(r1)res_ops.append(f{op})res_adj.append(False)tem r1[0] if r1[0].strip() not in [(, )] else r1[1]s_temp2 s_temp2.replace(f{tem}, )else:res re.findall(parttern2, s_temp3)result2.extend(res)for r in res:r1 r.replace( , ).split(f{op})result1.append(r1)res_ops.append(f{op})res_adj.append(True)str_ re.findall(r\([^\]*)\, ss)str_ list(set(str_))str_ [v.rstrip( \n) for v in str_]for i, fun in enumerate(result1):flag 0for item in fun:if any(item.strip() in v for v in str_) or any(item.strip() v for v in self.t_funcs):breakflag 1if flag 2 and result1[i] not in result1_n:result1_n.append(result1[i])result2_n.append(result2[i])res1_ops.append(res_ops[i])adj result1[i][0] in self.time_funcs or result1[i][0] in self.time_funcsres1_adj.append(adj)if result1_n:z zip(result1_n, result2_n, res1_ops, res1_adj)z1 sorted(z, keylambda x: len(x[1].replace( , )), reverseTrue)result1_n, result2_n, res1_ops, res1_adj zip(*z1)return result1_n, result2_n, res1_ops, res1_adjdef mysplit(self, s):分割字段:param s::return:s s.strip().replace(), ).replace((, )b [, -, *, /]res [s]result []for op in b:n_res []for item in res:n_res.extend(item.split(op))res n_resfor item in res:if as not in item:result.append(re.findall(r^[\w_*]$, item.replace( , ))[0])result list(set(res))return resultdef extact_func(self, s, func_name):res []s s[:-1].replace(f{func_name}(, , 1)com_idx [i for i, v in enumerate(s) if v ,]jd_com_idx []for i in com_idx:s1 s[0:i]if s1.count(() s1.count()):jd_com_idx.append(i)jd_com_idx.append(len(s))jd_com_idx.insert(0, 1)for i in range(1, len(jd_com_idx)):res.append(s[jd_com_idx[i - 1] 1:jd_com_idx[i]])return resdef sort_funcs(self, li):li sorted(li, keylambda x: x.count((), reverseTrue)li_n []for l in li:li_n.append(l)return li_ndef delete_text(self, event):self.entry.delete(0, END)self.filename def trans(self):passif __name__ __main__:pro Hive2Presto()pro.__int__()pro.main()
http://www.pierceye.com/news/252376/

相关文章:

  • 新浪推网站蜘蛛网站长工作职责
  • 百度网站排名关键词整站优化将wordpress部署
  • 做的ASP网站手机微站和网站数据同步
  • 爱站网长尾关键词挖掘工具营销类型网站怎么建设
  • 泉州seo网站推广在线查企业
  • 东营房地产网站建设wordpress文章关键字替换
  • 网站制作哪里好薇网站建设中最重要的环节是
  • 中山做营销型网站石家庄招投标公共服务平台官网
  • 修改wordpress的站点地址WordPress全屏图
  • 购物网站建设源码wordpress如何更改页脚背景颜色
  • 大型网站开发技术注册网站代码
  • 网站建设管理报告网站建设专家北京注安
  • 免费网站生成软件网站备案中的网站名称
  • 桐庐做网站手机里编辑 Wordpress
  • 外网怎么进入萧山网站优化
  • 做资源下载网站好吗婚恋网站建设公司排名
  • 网站后台管理系统管理员登录wordpress页面模板下载地址
  • 网站用户体验网络科技公司网站制作
  • seo中文全称是什么360搜索怎么做网站自然优化
  • 青岛网站建设技术外包文本资料分享网站 建设
  • 做好网站建设工作wordpress转发微信缩略图
  • 马鞍山网站开发流程设计师免费资源导航
  • 成功的网站不仅仅是优化排视频网站建设应该注意什么
  • 如何制作网站和软件查询关键词密度网站的网址有哪些
  • 网站服务器查询平台贵阳网站改版
  • 怎样查看网站总浏览量寿县有做网站开发的吗
  • 东莞网站建设价格价格网建企业
  • 做播放器电影网站需要多少钱6网络工程师证
  • dw怎么做网站标题图标网站建设进度表 免费下载
  • 西安哪些做网站的公司好做电子商务网站的意义