~/jobs/2018/python/dias/ex_test/ex.py

#===

import tarfile
from datetime import datetime

#for match -- NOT use
import re

## set read tgz path ##
path = "/export/raid2/koshida/DIAS/"
path = "/export/raid2/koshida/DIAS/XRAIN/kyoku1/SAPPORO001/ISHIKARI00/2018/12/22/07/ISHIKARI00-20181222-0700-P008-EL020000.tgz"
path = "/export/raid2/koshida/DIAS/XRAIN/kyoku2/TOUKYOU001/SHINYOKO00/2014/11/01/13/SHINYOKO00-20141101-1300-R005-EL020000.tgz"

## read tarinfo as tf(tar file)
#tf = tarfile.open('FURUTSUKI0-20110704-0900-R005-EL020000.tgz', 'r')
tf = tarfile.open(path, 'r')
## print tarinfo :: listup
tf.list()

## extract all
tf.extractall('./TMP')


#====

 

import re
#set pattern
pattern1 = re.compile('PHM0')
pattern2 = re.compile('PVM0')
pattern3 = re.compile('PRHV')

## get file info archived file name referred to 'ti'(tar info)##
for ti in tf:
    print ti.name, ti.size, \
        datetime.fromtimestamp(ti.mtime),oct(ti.mode), \
        ti.uname,ti.gname
    result1 = pattern1.search(ti.name)
    if result1 is None:
        print('NG')
    else:
        print('OK OK OK OK')
□~/jobs/2018/python/dias/ex_test/ex.py