Skip to content

Commit b419667

Browse files
committed
Rename add_data() to add_bytes()
1 parent d1d227e commit b419667

File tree

10 files changed

+26
-26
lines changed

10 files changed

+26
-26
lines changed

src/binding_generator/cffi_binding.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ pub fn write_cffi_module(
8989
};
9090

9191
if !editable || project_layout.python_module.is_none() {
92-
writer.add_data(
92+
writer.add_bytes(
9393
module.join("__init__.py"),
9494
None,
9595
cffi_init_file(&cffi_module_file_name).as_bytes(),
9696
false,
9797
)?;
98-
writer.add_data(
98+
writer.add_bytes(
9999
module.join("ffi.py"),
100100
None,
101101
cffi_declarations.as_bytes(),

src/binding_generator/pyo3_binding.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub fn write_bindings_module(
126126
} else {
127127
let module = PathBuf::from(ext_name);
128128
// Reexport the shared library as if it were the top level module
129-
writer.add_data(
129+
writer.add_bytes(
130130
module.join("__init__.py"),
131131
None,
132132
format!(

src/binding_generator/uniffi_binding.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ pub fn write_uniffi_module(
248248
};
249249

250250
if !editable || project_layout.python_module.is_none() {
251-
writer.add_data(module.join("__init__.py"), None, py_init.as_bytes(), false)?;
251+
writer.add_bytes(module.join("__init__.py"), None, py_init.as_bytes(), false)?;
252252
for binding in binding_names.iter() {
253253
writer.add_file(
254254
module.join(binding).with_extension("py"),

src/binding_generator/wasm_binding.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ if __name__ == '__main__':
5454
let launcher_path = Path::new(&metadata.get_distribution_escaped())
5555
.join(bin_name.replace('-', "_"))
5656
.with_extension("py");
57-
writer.add_data(&launcher_path, None, entrypoint_script.as_bytes(), true)?;
57+
writer.add_bytes(&launcher_path, None, entrypoint_script.as_bytes(), true)?;
5858
Ok(())
5959
}

src/module_writer/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub trait ModuleWriter {
3535
/// the appropriate unix permissions
3636
///
3737
/// For generated files, `source` is `None`.
38-
fn add_data(
38+
fn add_bytes(
3939
&mut self,
4040
target: impl AsRef<Path>,
4141
source: Option<&Path>,
@@ -60,14 +60,14 @@ pub trait ModuleWriterExt: ModuleWriter {
6060

6161
let file =
6262
File::open(source).with_context(|| format!("Failed to open {}", source.display()))?;
63-
self.add_data(target, Some(source), file, executable)
63+
self.add_bytes(target, Some(source), file, executable)
6464
.with_context(|| format!("Failed to write to {}", target.display()))?;
6565
Ok(())
6666
}
6767

6868
/// Add an empty file to the target path
6969
fn add_empty_file(&mut self, target: impl AsRef<Path>) -> Result<()> {
70-
self.add_data(target, None, io::empty(), false)
70+
self.add_bytes(target, None, io::empty(), false)
7171
}
7272
}
7373

@@ -231,14 +231,14 @@ pub fn write_dist_info(
231231
) -> Result<()> {
232232
let dist_info_dir = metadata24.get_dist_info_dir();
233233

234-
writer.add_data(
234+
writer.add_bytes(
235235
dist_info_dir.join("METADATA"),
236236
None,
237237
metadata24.to_file_contents()?.as_bytes(),
238238
false,
239239
)?;
240240

241-
writer.add_data(
241+
writer.add_bytes(
242242
dist_info_dir.join("WHEEL"),
243243
None,
244244
wheel_file(tags)?.as_bytes(),
@@ -256,7 +256,7 @@ pub fn write_dist_info(
256256
entry_points.push_str(&entry_points_txt(entry_type, scripts));
257257
}
258258
if !entry_points.is_empty() {
259-
writer.add_data(
259+
writer.add_bytes(
260260
dist_info_dir.join("entry_points.txt"),
261261
None,
262262
entry_points.as_bytes(),

src/module_writer/path_writer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl PathWriter {
3434
}
3535

3636
impl ModuleWriter for PathWriter {
37-
fn add_data(
37+
fn add_bytes(
3838
&mut self,
3939
target: impl AsRef<Path>,
4040
source: Option<&Path>,

src/module_writer/sdist_writer.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub struct SDistWriter {
3737
}
3838

3939
impl ModuleWriter for SDistWriter {
40-
fn add_data(
40+
fn add_bytes(
4141
&mut self,
4242
target: impl AsRef<Path>,
4343
source: Option<&Path>,
@@ -150,7 +150,7 @@ mod tests {
150150
let tmp_dir = TempDir::new()?;
151151
let mut writer = SDistWriter::new(&tmp_dir, &metadata, Override::empty(), None)?;
152152
assert!(writer.file_tracker.files.is_empty());
153-
writer.add_data("test", Some(Path::new("test")), empty(), true)?;
153+
writer.add_bytes("test", Some(Path::new("test")), empty(), true)?;
154154
assert_eq!(writer.file_tracker.files.len(), 1);
155155
writer.finish()?;
156156
tmp_dir.close()?;
@@ -161,12 +161,12 @@ mod tests {
161161
excludes.add("test*")?;
162162
excludes.add("!test2")?;
163163
let mut writer = SDistWriter::new(&tmp_dir, &metadata, excludes.build()?, None)?;
164-
writer.add_data("test1", Some(Path::new("test1")), empty(), true)?;
165-
writer.add_data("test3", Some(Path::new("test3")), empty(), true)?;
164+
writer.add_bytes("test1", Some(Path::new("test1")), empty(), true)?;
165+
writer.add_bytes("test3", Some(Path::new("test3")), empty(), true)?;
166166
assert!(writer.file_tracker.files.is_empty());
167-
writer.add_data("test2", Some(Path::new("test2")), empty(), true)?;
167+
writer.add_bytes("test2", Some(Path::new("test2")), empty(), true)?;
168168
assert!(!writer.file_tracker.files.is_empty());
169-
writer.add_data("yes", Some(Path::new("yes")), empty(), true)?;
169+
writer.add_bytes("yes", Some(Path::new("yes")), empty(), true)?;
170170
assert_eq!(writer.file_tracker.files.len(), 2);
171171
writer.finish()?;
172172
tmp_dir.close()?;

src/module_writer/wheel_writer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub struct WheelWriter {
3737
}
3838

3939
impl ModuleWriter for WheelWriter {
40-
fn add_data(
40+
fn add_bytes(
4141
&mut self,
4242
target: impl AsRef<Path>,
4343
source: Option<&Path>,
@@ -137,7 +137,7 @@ impl WheelWriter {
137137
let name = metadata24.get_distribution_escaped();
138138
let target = format!("{name}.pth");
139139
debug!("Adding {} from {}", target, python_path);
140-
self.add_data(target, None, python_path.as_bytes(), false)?;
140+
self.add_bytes(target, None, python_path.as_bytes(), false)?;
141141
} else {
142142
eprintln!(
143143
"⚠️ source code path contains non-Unicode sequences, editable installs may not work."

src/source_distribution.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ fn add_crate_to_source_distribution(
284284
let mut document = parse_toml_file(manifest_path, "Cargo.toml")?;
285285
rewrite_cargo_toml_readme(&mut document, manifest_path, readme_name)?;
286286
rewrite_cargo_toml(&mut document, manifest_path, known_path_deps)?;
287-
writer.add_data(
287+
writer.add_bytes(
288288
cargo_toml_path,
289289
Some(manifest_path),
290290
document.to_string().as_bytes(),
@@ -293,7 +293,7 @@ fn add_crate_to_source_distribution(
293293
} else if !skip_cargo_toml {
294294
let mut document = parse_toml_file(manifest_path, "Cargo.toml")?;
295295
rewrite_cargo_toml_readme(&mut document, manifest_path, readme_name)?;
296-
writer.add_data(
296+
writer.add_bytes(
297297
cargo_toml_path,
298298
Some(manifest_path),
299299
document.to_string().as_bytes(),
@@ -584,7 +584,7 @@ fn add_cargo_package_files_to_sdist(
584584
workspace_manifest_path.as_std_path(),
585585
&deps_to_keep,
586586
)?;
587-
writer.add_data(
587+
writer.add_bytes(
588588
root_dir.join(relative_workspace_cargo_toml),
589589
Some(workspace_manifest_path.as_std_path()),
590590
document.to_string().as_bytes(),
@@ -608,7 +608,7 @@ fn add_cargo_package_files_to_sdist(
608608
pyproject_toml_path,
609609
&relative_main_crate_manifest_dir.join("Cargo.toml"),
610610
)?;
611-
writer.add_data(
611+
writer.add_bytes(
612612
root_dir.join("pyproject.toml"),
613613
Some(pyproject_toml_path),
614614
rewritten_pyproject_toml.as_bytes(),
@@ -857,7 +857,7 @@ pub fn source_distribution(
857857
}
858858
}
859859

860-
writer.add_data(
860+
writer.add_bytes(
861861
root_dir.join("PKG-INFO"),
862862
None,
863863
metadata24.to_file_contents()?.as_bytes(),

tests/common/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct MockWriter {
1111
}
1212

1313
impl ModuleWriter for MockWriter {
14-
fn add_data(
14+
fn add_bytes(
1515
&mut self,
1616
target: impl AsRef<Path>,
1717
_source: Option<&Path>,

0 commit comments

Comments
 (0)