本文整理匯總了Python中src.tools.path.Path.is_file方法的典型用法代碼示例。如果您正苦於以下問題:Python Path.is_file方法的具體用法?Python Path.is_file怎麽用?Python Path.is_file使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類src.tools.path.Path
的用法示例。
在下文中一共展示了Path.is_file方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: init_database
# 需要導入模塊: from src.tools.path import Path [as 別名]
# 或者: from src.tools.path.Path import is_file [as 別名]
def init_database():
if Path.is_file(Path.db_path):
DB.set_conn(sqlite3.connect(Path.db_path))
else:
DB.set_conn(sqlite3.connect(Path.db_path))
with open(Path.sql_path) as sql_script:
DB.cursor.executescript(sql_script.read())
DB.commit()
示例2: getAnswerContentFromFile
# 需要導入模塊: from src.tools.path import Path [as 別名]
# 或者: from src.tools.path.Path import is_file [as 別名]
def getAnswerContentFromFile( answertmp = {}):
if not answertmp:
return
filepath_name = Ans2File.filepath(answertmp)
if Path.is_file(filepath_name):
with open(filepath_name, 'r') as f:
fileContent = f.read()
answertmp['content'] = fileContent
return
示例3: init_database
# 需要導入模塊: from src.tools.path import Path [as 別名]
# 或者: from src.tools.path.Path import is_file [as 別名]
def init_database():
if Path.is_file(Path.db_path):
Debug.logger.debug(u"Connect to the database...")
Debug.logger.debug(u"db_path: " + str(Path.db_path))
DB.set_conn(sqlite3.connect(Path.db_path))
else:
Debug.logger.debug(u"Create db file...")
DB.set_conn(sqlite3.connect(Path.db_path))
with open(Path.sql_path) as sql_script:
DB.cursor.executescript(sql_script.read())
DB.commit()
示例4: svContent2File
# 需要導入模塊: from src.tools.path import Path [as 別名]
# 或者: from src.tools.path.Path import is_file [as 別名]
def svContent2File( filepath_name , contentInHttp):
contentBefore=''
if Path.is_file(filepath_name):
with open(filepath_name ,'r') as f:
contentBefore = f.read()
def calcContent(contentBefore ,contentSave):#計算內容 是否保存
strContentSave = contentSave
contentBefore = unicode(contentBefore, errors='ignore')
if (contentSave.find(contentBefore[10:]) == -1):
strContentSave += '\n -----------------------------------------答案更新分割線------------------\n'
strContentSave += contentBefore
return strContentSave
content2SV = calcContent(contentBefore , contentInHttp)
with open(filepath_name ,'w') as f:
f.write(content2SV)
return
示例5: addFileSave
# 需要導入模塊: from src.tools.path import Path [as 別名]
# 或者: from src.tools.path.Path import is_file [as 別名]
def addFileSave(answertmp={}):
save_content = hashlib.md5(answertmp['content']).hexdigest()
filepath_name = Ans2File.filepath(answertmp)
def isUpdateContent( save_content ,questionID , answerID):#是否更答案文本內容
answerHref = 'http://www.zhihu.com/question/{0}/answer/{1}'.format(questionID, answerID)
Var = DB.cursor.execute(
"select content from Answer where href = ?", (answerHref,)).fetchone()
if not Var:
Debug.logger.debug(u'讀答案md5失敗')
return False #初始為空 則默認插入
return Var[0] == save_content
bsaved = isUpdateContent(save_content , answertmp['question_id'] , answertmp['answer_id'])
if not Path.is_file(filepath_name):
bsaved = False#數據庫中有,文件沒有
if not bsaved :
Ans2File.svContent2File(filepath_name , answertmp['content'])
answertmp['content'] = str(save_content)
return
示例6: start
# 需要導入模塊: from src.tools.path import Path [as 別名]
# 或者: from src.tools.path.Path import is_file [as 別名]
def start(self):
# 檢查更新
self.check_update()
# 登錄
login = Login()
zhihu_client = login.get_login_client()
Worker.set_zhihu_client(zhihu_client)
Debug.logger.info(u"開始讀取ReadList.txt設置信息")
if not Path.is_file(u'./ReadList.txt'):
# 當ReadList不存在的時候自動創建之
with open(u'./ReadList.txt', u'w') as read_list:
read_list.close()
print Debug.logger.info(u"ReadList.txt 內容為空,自動退出")
return
book_counter = self.read_list()
Debug.logger.info(u"所有書籍製作完成。")
Debug.logger.info(u"本次共製作書籍{0}本".format(book_counter))
Debug.logger.info(u"感謝您的使用")
Debug.logger.info(u"點按任意鍵退出")
return