MCPcopy Create free account
hub / github.com/apache/datafusion / update_version_cargo_toml

Function update_version_cargo_toml

dev/update_arrow_deps.py:81–106  ·  view source on GitHub ↗
(cargo_toml, new_version)

Source from the content-addressed store, hash-verified

79
80
81def update_version_cargo_toml(cargo_toml, new_version):
82 print('updating {}'.format(cargo_toml.absolute()))
83 with open(cargo_toml) as f:
84 data = f.read()
85
86 doc = tomlkit.parse(data)
87
88 for section in ("dependencies", "dev-dependencies"):
89 for (dep_name, constraint) in doc.get(section, {}).items():
90 if dep_name in ("arrow", "parquet", "arrow-flight"):
91 if type(constraint) == tomlkit.items.String:
92 # handle constraint that is (only) a string like '12',
93 doc[section][dep_name] = new_version
94 elif type(constraint) == dict:
95 # handle constraint that is itself a struct like
96 # {'version': '12', 'features': ['prettyprint']}
97 doc[section][dep_name]["version"] = new_version
98 elif type(constraint) == tomlkit.items.InlineTable:
99 # handle constraint that is itself a struct like
100 # {'version': '12', 'features': ['prettyprint']}
101 doc[section][dep_name]["version"] = new_version
102 else:
103 print("Unknown type for {} {}: {}", dep_name, constraint, type(constraint))
104
105 with open(cargo_toml, 'w') as f:
106 f.write(tomlkit.dumps(doc))
107
108
109def main():

Callers 1

mainFunction · 0.85

Calls 6

formatMethod · 0.80
readMethod · 0.80
parseMethod · 0.45
itemsMethod · 0.45
getMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…