mirror of
https://github.com/mtshiba/pylyzer.git
synced 2025-08-03 13:58:17 +00:00
Fix __pycache__ location
This commit is contained in:
parent
85ca5765b6
commit
ac629ab976
4 changed files with 16 additions and 9 deletions
|
@ -1,5 +1,7 @@
|
|||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use erg_common::config::Input;
|
||||
use erg_compiler::hir::{HIR, Expr};
|
||||
use erg_compiler::ty::HasType;
|
||||
|
||||
|
@ -34,12 +36,16 @@ pub fn gen_decl_er(hir: HIR) -> DeclFile {
|
|||
DeclFile { filename, code }
|
||||
}
|
||||
|
||||
pub fn dump_decl_er(hir: HIR) {
|
||||
pub fn dump_decl_er(input: Input, hir: HIR) {
|
||||
let file = gen_decl_er(hir);
|
||||
if !std::path::Path::new("__pycache__").exists() {
|
||||
std::fs::create_dir("__pycache__").unwrap();
|
||||
let mut path = if let Input::File(path) = input { path } else { PathBuf::new() };
|
||||
path.pop();
|
||||
path.push("__pycache__");
|
||||
let pycache_dir = path.as_path();
|
||||
if !pycache_dir.exists() {
|
||||
std::fs::create_dir(pycache_dir).unwrap();
|
||||
}
|
||||
let f = std::fs::File::create(format!("__pycache__/{}", file.filename)).unwrap();
|
||||
let f = std::fs::File::create(pycache_dir.join(file.filename)).unwrap();
|
||||
let mut f = std::io::BufWriter::new(f);
|
||||
f.write_all(file.code.as_bytes()).unwrap();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue