MCPcopy Index your code
hub / github.com/reflex-dev/reflex / get_different_packages

Function get_different_packages

reflex/utils/exec.py:129–170  ·  view source on GitHub ↗

Get the packages that are different between two package JSON contents. Args: old_package_json_content: The content of the old package JSON. new_package_json_content: The content of the new package JSON. Returns: A tuple containing two `Change` named tuples:

(
    old_package_json_content: PackageJson,
    new_package_json_content: PackageJson,
)

Source from the content-addressed store, hash-verified

127
128
129def get_different_packages(
130 old_package_json_content: PackageJson,
131 new_package_json_content: PackageJson,
132) -> tuple[Change, Change]:
133 """Get the packages that are different between two package JSON contents.
134
135 Args:
136 old_package_json_content: The content of the old package JSON.
137 new_package_json_content: The content of the new package JSON.
138
139 Returns:
140 A tuple containing two `Change` named tuples:
141 - The first `Change` contains the changes in the `dependencies` section.
142 - The second `Change` contains the changes in the `devDependencies` section.
143 """
144
145 def get_changes(old: dict[str, str], new: dict[str, str]) -> Change:
146 """Get the changes between two dictionaries.
147
148 Args:
149 old: The old dictionary of packages.
150 new: The new dictionary of packages.
151
152 Returns:
153 A `Change` named tuple containing the added and removed packages.
154 """
155 old_keys = set(old.keys())
156 new_keys = set(new.keys())
157 added = new_keys - old_keys
158 removed = old_keys - new_keys
159 return Change(added=added, removed=removed)
160
161 dependencies_change = get_changes(
162 old_package_json_content.get("dependencies", {}),
163 new_package_json_content.get("dependencies", {}),
164 )
165 dev_dependencies_change = get_changes(
166 old_package_json_content.get("devDependencies", {}),
167 new_package_json_content.get("devDependencies", {}),
168 )
169
170 return dependencies_change, dev_dependencies_change
171
172
173def kill(proc_pid: int):

Callers 1

Calls 2

get_changesFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected