当前位置: 首页>>代码示例>>Python>>正文


Python Common.timely_filename方法代码示例

本文整理汇总了Python中common.Common.timely_filename方法的典型用法代码示例。如果您正苦于以下问题:Python Common.timely_filename方法的具体用法?Python Common.timely_filename怎么用?Python Common.timely_filename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common.Common的用法示例。


在下文中一共展示了Common.timely_filename方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: verify

# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import timely_filename [as 别名]
 def verify(self):
     self.project.log("transaction", "Verifying all downloaded files...", "highlight", True)
     verification_file = os.path.join(self.project.working_dir, Common.timely_filename("verification", ".csv"))
     errors = 0
     pct = 0
     tot_hashes = 0
     with open(verification_file, 'w') as f:
         f.write("TIME_PROCESSED,REMOTE_FILE,LOCAL_FILE,REMOTE_HASH,LOCAL_HASH,MATCH\n")
         for item in self.verification:
             rh = ""
             match = ""
             lh = Common.hashfile(open(item['local_file'], 'rb'), hashlib.md5())
             lf = item['local_file']
             rf = item['remote_file']
             if 'remote_hash' in item:
                 tot_hashes += 1
                 rh = item['remote_hash']
                 if lh == item['remote_hash']:
                     match = "YES"
                 else:
                     match = "NO"
                     errors += 1
                     self.project.log("exception", "Verification failed for remote file {} and local file {}".format(rf,lf), "critical", True)
             else:
                 rh = "NONE PROVIDED"
                 match = "N/A"
             f.write('"{date}","{rf}","{lf}","{rh}","{lh}","{m}"\n'.format(date=Common.utc_get_datetime_as_string(),rf=rf,lf=lf,rh=rh,lh=lh,m=match))
     pct = ((tot_hashes - errors) / tot_hashes) * 100
     self.project.log("transaction", "Verification of {} items completed with {} errors. ({:.2f}% Success rate)".format(tot_hashes, errors, pct), "highlight", True)
开发者ID:LucaBongiorni,项目名称:searchgiant_cli,代码行数:31,代码来源:GoogleDrive.py

示例2: metadata

# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import timely_filename [as 别名]
 def metadata(self):
     file_list_path = os.path.join(self.project.working_dir, Common.timely_filename("file_list",".csv"))
     with open(file_list_path, 'w') as csv:
         csv.write("filename,bytes,size,revision,modified,mimeType,isDir,root,clientmTime\n")
         for f in self.files:
             row = []
             row.append('None' if 'path' not in f else repr(f['path']))
             row.append('0' if 'bytes' not in f else repr(f['bytes']))
             row.append('None' if 'size' not in f else repr(f['size']))
             row.append('None' if 'revision' not in f else repr(f['revision']))
             row.append('None' if 'modified' not in f else repr(f['modified']))
             row.append('None' if 'mime_type' not in f else repr(f['mime_type']))
             row.append('None' if 'is_dir' not in f else repr(f['is_dir']))
             row.append('None' if 'root' not in f else repr(f['root']))
             row.append('None' if 'client_mtime' not in f else repr(f['client_mtime']))
             csv.write(','.join('"' + item + '"' for item in row) + "\n")
     csv.close()
开发者ID:LucaBongiorni,项目名称:searchgiant_cli,代码行数:19,代码来源:Dropbox.py

示例3: metadata

# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import timely_filename [as 别名]
    def metadata(self):
        self.project.log("transaction", "Generating metadata CSV File...", "info", True)
        if not self.files:
            self.initialize_items()

        fname = Common.timely_filename("FileList", ".csv")
        metadata_file = os.path.join(self.project.working_dir, fname)
        IO.put("Writing CSV File '{}'".format(metadata_file))

        f = open(metadata_file, "w")

        columns = ("id,title,fileExtension,fileSize,createdDate,modifiedDate,modifiedByMeDate,md5Checksum,"
                   "kind,version,parents,restricted,hidden,trashed,starred,viewed,markedViewedByMeDate,lastViewedByMeDate,"
                   "lastModifyingUserName,writersCanShare,sharedWithMeDate,sharingUser,sharingUserEmail,ownerNames{}\n")

        f.write(columns)
        for i in self.files:
            row2 = []
            # Data normalization
            row2.append('None' if 'id' not in i else repr(i['id']))
            row2.append('None' if 'title' not in i else '"' + i['title'] + '"')
            row2.append('None' if 'fileExtension' not in i else repr(i['fileExtension']))
            row2.append('None' if 'fileSize' not in i else i['fileSize'])
            row2.append('None' if 'createdDate' not in i else i['createdDate'])
            row2.append('None' if 'modifiedDate' not in i else i['modifiedDate'])
            row2.append('None' if 'modifiedByMeDate' not in i else i['modifiedByMeDate'])
            row2.append('None' if 'md5Checksum' not in i else '"' + i['md5Checksum'] + '"')
            row2.append('None' if 'kind' not in i else repr(i['kind']))
            row2.append('None' if 'version' not in i else i['version'])
            if 'parents' not in i or len(i['parents']) == 0:
                row2.append('None')
            else:
                parStr = '"'
                for p in i['parents']:
                    parStr = parStr + str(p['id']) + ','
                parStr = parStr[:len(parStr) - 1]
                parStr = parStr + '"'
                row2.append(parStr)

            row2.append('None' if 'labels' not in i else repr(i['labels']['restricted']))
            row2.append('None' if 'labels' not in i else repr(i['labels']['hidden']))
            row2.append('None' if 'labels' not in i else repr(i['labels']['trashed']))
            row2.append('None' if 'labels' not in i else repr(i['labels']['starred']))
            row2.append('None' if 'labels' not in i else repr(i['labels']['viewed']))
            row2.append('None' if 'markedViewedByMeDate' not in i else i['markedViewedByMeDate'])
            row2.append('None' if 'lastViewedByMeDate' not in i else i['lastViewedByMeDate'])
            row2.append('None' if 'lastModifyingUserName' not in i else '"' + i['lastModifyingUserName'] + '"')
            row2.append('None' if 'writersCanShare' not in i else i['writersCanShare'])
            row2.append('None' if 'sharedWithMeDate' not in i else i['sharedWithMeDate'])
            row2.append('None' if 'sharingUser' not in i else '"' + i['sharingUser']['displayName'] + '"')
            row2.append('None' if 'sharingUser' not in i else '"' + i['sharingUser']['emailAddress'] + '"')
            if 'ownerNames' not in i or len(i['ownerNames']) == 0:
                row2.append('None')
            else:
                ownStr = '"'
                for o in i['ownerNames']:
                    ownStr = ownStr + str(o) + ','
                ownStr = ownStr[:len(ownStr) - 1]
                ownStr = ownStr + '"'
                row2.append(ownStr)

            rowStr = ""
            for r in row2:
                rowStr = rowStr + str(r) + ","
            rowStr = rowStr[:len(rowStr) - 1]
            f.write(rowStr + '\n')

        f.close()
开发者ID:LucaBongiorni,项目名称:searchgiant_cli,代码行数:70,代码来源:GoogleDrive.py

示例4: metadata

# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import timely_filename [as 别名]
 def metadata(self):
     msg_list_path = os.path.join(self.project.working_dir, Common.timely_filename("message_list",".csv"))
     with open(msg_list_path, 'w') as f:
         f.write("id,internalDate,labels,headerDate,To,From,Subject,snippet,threadId\n")
     self.metadata_file = msg_list_path
开发者ID:LucaBongiorni,项目名称:searchgiant_cli,代码行数:7,代码来源:GMail.py


注:本文中的common.Common.timely_filename方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。