Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
chore/copy deps file
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya-06 committed May 2, 2024
1 parent 9b21d4e commit a566875
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions benchmark_copy/parse_dependencies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import os
import sys

begin = False
package_version = {}
with open('./Cargo.toml') as f:
for line in f:
if '[' == line[0]:
begin = False
if 'dependencies' in line:
begin = True
continue

if begin:
sep = line.find('=')
package_version[line[:sep-1].strip()] = line[sep+2:].strip()

for dir_path in ["./libs/iceberg/", "./libs/rest/", "./libs/test_utils/"]:
r = open(dir_path + "Cargo.toml")
w = open(dir_path + "Cargo_n.toml", 'w')
begin = False
for r_line in r:
if '[' == r_line[0]:
begin = False
if 'dependencies' in r_line:
begin = True
w.write(r_line)
continue

if begin:
sep = r_line.find('=')
package = r_line[:sep-1].strip()
if package in package_version:
w.writelines([f"{package} = {package_version[package]}", "\n"])
else:
w.write(r_line)
else:
w.write(r_line)
r.close()
w.close()
os.remove(dir_path + "Cargo.toml")
os.rename(dir_path + "Cargo_n.toml", dir_path + "Cargo.toml")

0 comments on commit a566875

Please sign in to comment.