本文整理汇总了Python中utility.Utility.construct_feed_file_name方法的典型用法代码示例。如果您正苦于以下问题:Python Utility.construct_feed_file_name方法的具体用法?Python Utility.construct_feed_file_name怎么用?Python Utility.construct_feed_file_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utility.Utility
的用法示例。
在下文中一共展示了Utility.construct_feed_file_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: place_feed_file
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import construct_feed_file_name [as 别名]
def place_feed_file(cls, feed_dir, url_base, item_id):
"""Retrieve and places feed files for use by the Enricher modules.
Args:
feed_dir (str): Destination directory for feed files
url_base (str): Base URL for hosted feed files
item_id(str): For FCC, this is the two-letter ("CA" or "TN",
for example), which is used in the retrieval of the feed file
as well as the construction of the local feed file name. For
MCC this is the MCC, but in string form. Not integer.
"""
destination_file = Utility.construct_feed_file_name(feed_dir,
item_id)
temp_file = "%s.TEMP" % destination_file
origin_url = FeedManager.get_source_url(url_base, item_id)
msg = "FeedManager: Downloading %s to %s" % (origin_url, temp_file)
print(msg)
response = requests.get(origin_url, stream=True)
with open(temp_file, 'wb') as out_file:
for chunk in response.iter_content(chunk_size=1024):
if chunk:
out_file.write(chunk)
time.sleep(1)
print("FeedManager: Moving %s to %s" % (temp_file, destination_file))
os.rename(temp_file, destination_file)
return destination_file