Skip to content

Commit

Permalink
build: update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
mtshiba committed Jul 26, 2023
1 parent d9d355e commit 3d2cc35
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 27 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions crates/py2erg/gen_decl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,21 @@ pub struct DeclFileGenerator {

impl DeclFileGenerator {
pub fn new(input: &Input, status: CheckStatus) -> Self {
let (timestamp, hash) = if let Some(py_file_path) = input.path() {
let (timestamp, hash) = {
let py_file_path = input.path();
let metadata = std::fs::metadata(py_file_path).unwrap();
let dummy_hash = metadata.len();
(metadata.modified().unwrap(), dummy_hash)
} else {
let now = std::time::SystemTime::now();
(now, now.elapsed().unwrap().as_secs())
};
let status = PylyzerStatus {
status,
file: input.unescaped_path().into(),
file: input.path().into(),
timestamp,
hash,
};
let code = format!("{status}\n");
Self {
filename: input.unescaped_filename().replace(".py", ".d.er"),
filename: input.filename().replace(".py", ".d.er"),
namespace: "".to_string(),
code,
}
Expand Down Expand Up @@ -148,7 +146,7 @@ pub fn reserve_decl_er(input: Input) {
if !pycache_dir.exists() {
std::fs::create_dir(pycache_dir).unwrap();
}
let filename = input.unescaped_filename();
let filename = input.filename();
let mut path = pycache_dir.join(filename);
path.set_extension("d.er");
if !path.exists() {
Expand Down
18 changes: 6 additions & 12 deletions src/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,22 +185,19 @@ impl PythonAnalyzer {
reserve_decl_er(self.cfg.input.clone());
}
let py_code = self.cfg.input.read();
let filename = self.cfg.input.unescaped_filename();
let filename = self.cfg.input.filename();
println!("{BLUE}Start checking{RESET}: {filename}");
match self.analyze(py_code, "exec") {
Ok(artifact) => {
if !artifact.warns.is_empty() {
println!(
"{YELLOW}Found {} warnings{RESET}: {}",
artifact.warns.len(),
self.cfg.input.unescaped_filename()
self.cfg.input.filename()
);
artifact.warns.write_all_stderr();
}
println!(
"{GREEN}All checks OK{RESET}: {}",
self.cfg.input.unescaped_filename()
);
println!("{GREEN}All checks OK{RESET}: {}", self.cfg.input.filename());
if self.cfg.dist_dir.is_some() {
dump_decl_er(
self.cfg.input.clone(),
Expand All @@ -216,21 +213,18 @@ impl PythonAnalyzer {
println!(
"{YELLOW}Found {} warnings{RESET}: {}",
artifact.warns.len(),
self.cfg.input.unescaped_filename()
self.cfg.input.filename()
);
artifact.warns.write_all_stderr();
}
let code = if artifact.errors.is_empty() {
println!(
"{GREEN}All checks OK{RESET}: {}",
self.cfg.input.unescaped_filename()
);
println!("{GREEN}All checks OK{RESET}: {}", self.cfg.input.filename());
0
} else {
println!(
"{RED}Found {} errors{RESET}: {}",
artifact.errors.len(),
self.cfg.input.unescaped_filename()
self.cfg.input.filename()
);
artifact.errors.write_all_stderr();
1
Expand Down

0 comments on commit 3d2cc35

Please sign in to comment.