Compare commits

...

5 Commits

Author SHA1 Message Date
Gilles Boccon-Gibod 4a8e612c6e update rust list 2023-10-10 21:29:39 -07:00
Gilles Boccon-Gibod 4e71ec5738 remove stale comment 2023-10-10 20:36:48 -07:00
Gilles Boccon-Gibod d8e699b588 use the new yaml file instead of the previous CSV file 2023-10-07 23:10:49 -07:00
Gilles Boccon-Gibod dfa9131192 Merge pull request #311 from zxzxwu/rust
Fix Rust lints
2023-10-06 13:37:47 -07:00
Josh Wu 88c801b4c2 Replace or_insert_with with or_default 2023-10-06 18:02:46 +08:00
6 changed files with 1642 additions and 366 deletions
+813 -173
View File
File diff suppressed because it is too large Load Diff
+1 -3
View File
@@ -70,9 +70,7 @@ async fn main() -> PyResult<()> {
let mut seen_adv_cache = seen_adv_clone.lock().unwrap();
let expiry_duration = time::Duration::from_secs(cli.dedup_expiry_secs);
let advs_from_addr = seen_adv_cache
.entry(addr_bytes)
.or_insert_with(collections::HashMap::new);
let advs_from_addr = seen_adv_cache.entry(addr_bytes).or_default();
// we expect cache hits to be the norm, so we do a separate lookup to avoid cloning
// on every lookup with entry()
let show = if let Some(prev) = advs_from_addr.get_mut(&data_units) {
+2 -5
View File
@@ -143,10 +143,7 @@ pub(crate) fn probe(verbose: bool) -> anyhow::Result<()> {
);
if let Some(s) = serial {
println!("{:26}{}", " Serial:".green(), s);
device_serials_by_id
.entry(device_id)
.or_insert(HashSet::new())
.insert(s);
device_serials_by_id.entry(device_id).or_default().insert(s);
}
if let Some(m) = mfg {
println!("{:26}{}", " Manufacturer:".green(), m);
@@ -314,7 +311,7 @@ impl ClassInfo {
self.protocol,
self.protocol_name()
.map(|s| format!(" [{}]", s))
.unwrap_or_else(String::new)
.unwrap_or_default()
)
}
}
File diff suppressed because it is too large Load Diff
+1
View File
@@ -91,6 +91,7 @@ development =
mypy == 1.5.0
nox >= 2022
pylint == 2.15.8
pyyaml >= 6.0
types-appdirs >= 1.4.3
types-invoke >= 1.7.3
types-protobuf >= 4.21.0
+13 -13
View File
@@ -14,25 +14,25 @@
# -----------------------------------------------------------------------------
# This script generates a python-syntax list of dictionary entries for the
# company IDs listed at: https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers/
# The input to this script is the CSV file that can be obtained at that URL
# company IDs listed at:
# https://bitbucket.org/bluetooth-SIG/public/src/main/assigned_numbers/company_identifiers/company_identifiers.yaml
# The input to this script is the YAML file that can be obtained at that URL
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# Imports
# -----------------------------------------------------------------------------
import sys
import csv
import yaml
# -----------------------------------------------------------------------------
with open(sys.argv[1], newline='') as csvfile:
reader = csv.reader(csvfile, delimiter=',', quotechar='"')
lines = []
for row in reader:
if len(row) == 3 and row[1].startswith('0x'):
company_id = row[1]
company_name = row[2]
escaped_company_name = company_name.replace('"', '\\"')
lines.append(f' {company_id}: "{escaped_company_name}"')
with open(sys.argv[1], "r") as yaml_file:
root = yaml.safe_load(yaml_file)
companies = {}
for company in root["company_identifiers"]:
companies[company["value"]] = company["name"]
print(',\n'.join(reversed(lines)))
for company_id in sorted(companies.keys()):
company_name = companies[company_id]
escaped_company_name = company_name.replace('"', '\\"')
print(f' 0x{company_id:04X}: "{escaped_company_name}",')