commonutil.pathtag

路徑為基礎的標記或巨集支援 / Path-based Tag or Macro Support

parse_template(v)[source]

將輸入的檔名與路徑關鍵字代換字串轉換為後續供代換作業的物件

Translate given string which contained path-tag macros into match object

Parameters:v – 要轉換的代換字串 / Macro string
Returns:供代換作業使用的物件 / Match object for substitute operation
replace(xtrule, f_mobj, p_mobj, filemtime_dtobj=None)[source]

執行檔名與路徑關鍵字代換字串作業

Perform tag replacement by given match rule object

Parameters:
  • xtrule – 從 parse_time_tag_template() 函數取得的代換作業參數物件 / Match rule object get from parse_time_tag_template() function
  • f_mobj – 檔案名稱的 regex match object / regex match object of file name
  • p_mobj – 檔案路徑的 regex match object / regex match object of file path (folder part)
  • filemtime_dtobj=None – 檔案的變更時間物件 (已經偏移完成) / datetime.datetime object of the file modify time (must shift to desired time zone before pass in)
Returns:

經過代換的字串 / Result string