MCPcopy Index your code
hub / github.com/BrendanParmer/NodeToPython / download_file

Function download_file

tools/node_settings_generator/parse_nodes.py:112–135  ·  view source on GitHub ↗
(filepath: str, version: Version, local_path: str)

Source from the content-addressed store, hash-verified

110 process_attr(data, section, node, version)
111
112def download_file(filepath: str, version: Version, local_path: str) -> bool:
113 file_url = f"https://docs.blender.org/api/{version.point_str()}/{filepath}"
114
115 headers_ = {'User-Agent': 'Mozilla/5.0'}
116
117 req = urllib.request.Request(file_url, headers=headers_)
118
119 if not os.path.exists(os.path.dirname(local_path)):
120 os.makedirs(os.path.dirname(local_path))
121
122 NUM_TRIES = 10
123 for i in range(NUM_TRIES):
124 try:
125 with urllib.request.urlopen(req) as response:
126 with open(local_path, 'wb') as file:
127 file.write(response.read())
128 break
129 except Exception as e:
130 if i == NUM_TRIES - 1:
131 raise e
132 time.sleep(1.0)
133
134 print(f"Downloaded {file_url} to {local_path}")
135 return True
136
137
138def get_subclasses(current: str, parent: str, root_path: str,

Callers 1

get_subclassesFunction · 0.85

Calls 1

point_strMethod · 0.80

Tested by

no test coverage detected