hashedassets

Software screenshot:
hashedassets
Dettagli del software:
Versione: 0.3.1.1
Data di caricamento: 12 May 15
Sviluppatore: Filip Noetzel
Licenza: Libero
Popolarità: 6

Rating: 1.0/5 (Total Votes: 1)

hashedassets è uno strumento da riga di comando che copia i file nomi in base al loro contenuto. & Nbsp; Si scrive anche una mappa di ciò che è stato rinominato in quanto, in modo da poter trovare i file.
Scopo principale di questo è che è possibile aggiungere un lontano futuro Valida intestazione per i componenti. Utilizzando i nomi di file hash basato è molto meglio che usare il tuo numero di revisione $ VCS, perché solo gli utenti devono scaricare i file che non cambiano.
Creazione di alcuni file di origine
In primo luogo, creiamo un file da hash:
>>> Sistema ("input mkdir /")
>>> Sistema ("Ingresso mkdir / subdir /")
>>> Sistema ("mappe mkdir /")
>>> Con open ("input / pippo.txt", "w") in formato:
... File.write ("foo")
>>> Con open ("input / subdir / bar.txt", "w") in formato:
... File.write ("bar")
>>> Sistema ('toccare -t200504072213.12 ingresso / foo.txt')
Utilizzo semplice
>>> Sistema ("hashedassets mappe / ingresso map.txt / *. Ingresso txt / * / *. Uscita txt /")
'output' mkdir
'input / foo.txt' cp 'uscita / C-7Hteo_D9vJXQ3UfzxbwnXaijM.txt'
cp 'input / subdir / bar.txt' 'uscita / Ys23Ag_5IOWqZCw9QGaVDdHwH00.txt'
>>> Stampare aperto ("mappe / map.txt"). Read ()
subdir / bar.txt: Ys23Ag_5IOWqZCw9QGaVDdHwH00.txt
foo.txt: C-7Hteo_D9vJXQ3UfzxbwnXaijM.txt

>>> Sistema ("Uscita ls /")
C-7Hteo_D9vJXQ3UfzxbwnXaijM.txt
Ys23Ag_5IOWqZCw9QGaVDdHwH00.txt
>>> Sistema ("LS mappe /")
map.txt
Livello di registrazione
Se diciamo il comando di essere tranquillo, non stampa quello che sta facendo:
>>> System ("/ *. Txt ingresso hashedassets -q ingresso mappe / map2.txt / * / *. Uscita txt /")
Se diciamo il comando per essere più dettagliato, esso registra maggiori informazioni:
>>> System ("/ *. Txt ingresso hashedassets -vvv ingresso mappe / map3.txt / * / *. Uscita txt /")
Livello Debug impostato su 10
'input / foo.txt' cp 'uscita / C-7Hteo_D9vJXQ3UfzxbwnXaijM.txt'
cp 'input / subdir / bar.txt' 'uscita / Ys23Ag_5IOWqZCw9QGaVDdHwH00.txt'
Tempo di modifica è anche conservato:
>>> Old_stat = os.stat ("input / foo.txt")
>>> New_stat = os.stat ("Uscita / C-7Hteo_D9vJXQ3UfzxbwnXaijM.txt")
>>> [(Getattr (old_stat, prop) == getattr (new_stat, prop))
... Per prop in ('st_mtime', 'st_atime', 'st_ino',)]
[Vero, Vero, Falso]
Possiamo facilmente farlo con più formati:
JavaScript
>>> System ("hashedassets -n mappe my_callback / map.js input / *. Ingresso txt / * / *. Uscita txt /")
'input / foo.txt' cp 'uscita / C-7Hteo_D9vJXQ3UfzxbwnXaijM.txt'
cp 'input / subdir / bar.txt' 'uscita / Ys23Ag_5IOWqZCw9QGaVDdHwH00.txt'
>>> Print open ("mappe / map.js"). Read ()
var my_callback = {
& Nbsp; "foo.txt": "C-7Hteo_D9vJXQ3UfzxbwnXaijM.txt",
& Nbsp; "subdir / bar.txt": "Ys23Ag_5IOWqZCw9QGaVDdHwH00.txt"
};
JSON
>>> System ("hashedassets -n mappe my_callback / ingresso map.json / *. Ingresso txt / * / *. Uscita txt /")
'input / foo.txt' cp 'uscita / C-7Hteo_D9vJXQ3UfzxbwnXaijM.txt'
cp 'input / subdir / bar.txt' 'uscita / Ys23Ag_5IOWqZCw9QGaVDdHwH00.txt'
>>> Stampare aperto ("mappe / map.json"). Read ()
{
& Nbsp; "foo.txt": "C-7Hteo_D9vJXQ3UfzxbwnXaijM.txt",
& Nbsp; "subdir / bar.txt": "Ys23Ag_5IOWqZCw9QGaVDdHwH00.txt"
}
JSONP
>>> System ("hashedassets -n mappe my_callback / ingresso map.jsonp / *. Ingresso txt / * / *. Uscita txt /")
'input / foo.txt' cp 'uscita / C-7Hteo_D9vJXQ3UfzxbwnXaijM.txt'
cp 'input / subdir / bar.txt' 'uscita / Ys23Ag_5IOWqZCw9QGaVDdHwH00.txt'
>>> Stampare aperto ("mappe / map.jsonp"). Read ()
my_callback ({
& Nbsp; "foo.txt": "C-7Hteo_D9vJXQ3UfzxbwnXaijM.txt",
& Nbsp; "subdir / bar.txt": "Ys23Ag_5IOWqZCw9QGaVDdHwH00.txt"
});
Insolenza
Sass è un linguaggio meta in cima CSS.
>>> System ("hashedassets -n mappe my_callback / map.scss input / *. Ingresso txt / * / *. Uscita txt /")
'input / foo.txt' cp 'uscita / C-7Hteo_D9vJXQ3UfzxbwnXaijM.txt'
cp 'input / subdir / bar.txt' 'uscita / Ys23Ag_5IOWqZCw9QGaVDdHwH00.txt'
>>> Stampare aperto ("mappe / map.scss"). Read ()
mixin my_callback ($ direttiva, $ path) {
& Nbsp;if $ path == "subdir / bar.txt" {# {$ direttiva}: url ("Ys23Ag_5IOWqZCw9QGaVDdHwH00.txt"); }
& Nbsp;else se $ path == "foo.txt" {# {$ direttiva}: url ("C-7Hteo_D9vJXQ3UfzxbwnXaijM.txt"); }
& Nbsp;else {
& Nbsp;warn "Non hai trovato" # {$ path} "nella lista delle attività";
& Nbsp; # {$ direttiva}: url ($ path);
& Nbsp;}
}
PHP
>>> System ("hashedassets -n mappe my_callback / ingresso map.php / *. Ingresso txt / * / *. Uscita txt /")
'input / foo.txt' cp 'uscita / C-7Hteo_D9vJXQ3UfzxbwnXaijM.txt'
cp 'input / subdir / bar.txt' 'uscita / Ys23Ag_5IOWqZCw9QGaVDdHwH00.txt'
>>> Stampare aperto ("mappe / map.php"). Read ()
$ My_callback = array (
& Nbsp; "subdir / bar.txt" => "Ys23Ag_5IOWqZCw9QGaVDdHwH00.txt",
& Nbsp; "foo.txt" => "C-7Hteo_D9vJXQ3UfzxbwnXaijM.txt",
)
Sed
Possiamo anche generare uno script sed che fa le sostituzioni per noi:
>>> Sistema ("hashedassets -n mappe my_callback / ingresso map.sed / *. Ingresso txt / * / *. Uscita txt /")
'input / foo.txt' cp 'uscita / C-7Hteo_D9vJXQ3UfzxbwnXaijM.txt'
cp 'input / subdir / bar.txt' 'uscita / Ys23Ag_5IOWqZCw9QGaVDdHwH00.txt'
>>> Print open ("mappe / map.sed"). Read ()
s / subdir / bar .txt / Ys23Ag_5IOWqZCw9QGaVDdHwH00 .txt / g
s / foo .txt / C-7Hteo_D9vJXQ3UfzxbwnXaijM .txt / g

Dovremmo essere in grado di utilizzare questo direttamente con sed
>>> Con open ("replaceme.html", "w") in formato:
... File.write (' bar ')
Lo script viene poi applicato in questo modo:
>>> System ("mappe -f sed / replaceme.html map.sed")
bar
Tuttavia, '.' non è trattata come wildcard, in modo che il seguente non funziona
>>> Con open ("replaceme2.html", "w") in formato:
... File.write (' bar ')
>>> System ("mappe -f sed / replaceme2.html map.sed")
bar
Definizione del tipo con -t
Il tipo di carta è indovinato dal nome del file, ma è possibile specificare pure:
>>> System ("hashedassets -t js cantguessmaptype ingresso / *. Ingresso txt / * / *. Uscita txt /")
'input / foo.txt' cp 'uscita / C-7Hteo_D9vJXQ3UfzxbwnXaijM.txt'
cp 'input / subdir / bar.txt' 'uscita / Ys23Ag_5IOWqZCw9QGaVDdHwH00.txt'
Specificare la lunghezza del nome del file con -l
>>> System ("hashedassets -l 10 mappe / ingresso shortmap.json / *. Ingresso txt / * / *. Uscita txt /")
'input / foo.txt' cp 'uscita / C-7Hteo_D9.txt'
cp 'input / subdir / bar.txt' 'uscita / Ys23Ag_5IO.txt'
>>> Sistema ("Uscita rm / uscita C-7Hteo_D9.txt / Ys23Ag_5IO.txt")
Definizione del digest con -d
>>> Sistema ("hashedassets -d mappe md5 / ingresso shortmap.json / *. Ingresso txt / * / *. Uscita txt /")
'input / foo.txt' cp 'uscita / rL0Y20zC-Fzt72VPzMSk2A.txt'
cp 'input / subdir / bar.txt' 'uscita / N7UdGUp1E-RbVvZSTy1R8g.txt'
>>> Sistema ("Uscita rm / uscita rL0Y20zC-Fzt72VPzMSk2A.txt / N7UdGUp1E-RbVvZSTy1R8g.txt")
Re-utilizzando una mappa
Il programma legge nelle mappe è creato in una corsa prima di copiare solo i file che non sono cambiati da allora. Così, i seguenti comandi non copiare alcun file:
>>> Sistema ("hashedassets mappe / map.scss input / *. Ingresso txt / * / *. Uscita txt /")
>>> Sistema ("hashedassets mappe / ingresso map.php / *. Ingresso txt / * / *. Uscita txt /")
>>> Sistema ("hashedassets mappe / map.js input / *. Ingresso txt / * / *. Uscita txt /")
>>> Sistema ("hashedassets mappe / ingresso map.json / *. Ingresso txt / * / *. Uscita txt /")
>>> Sistema ("hashedassets mappe / ingresso map.sed / *. Ingresso txt / * / *. Uscita txt /")
>>> Sistema ("hashedassets mappe / ingresso map.jsonp / *. Ingresso txt / * / *. Uscita txt /")
>>> Sistema ("hashedassets mappe / ingresso map.txt / *. Ingresso txt / * / *. Uscita txt /")
Se tocchiamo uno dei file di input intermedi, il file verrà letto ma non copiato perché il hashsum è la stessa:
>>> Sistema ('toccare -t200504072214.12 ingresso / foo.txt')
>>> Sistema ("hashedassets mappe / ingresso map.json / *. Ingresso txt / * / *. Uscita txt /")
Se cambiamo il contenuto del file, si otterrà un nuovo nome:
>>> Con open ("input / pippo.txt", "w") in formato:
... File.write ("foofoo")
>>> Sistema ("hashedassets mappe / ingresso map.json / *. Ingresso txt / * / *. Uscita txt /")
'uscita / C-7Hteo_D9vJXQ3UfzxbwnXaijM.txt' rm
'input / foo.txt' cp 'uscita / QIDaFD7KLKQh0l5O6b8exdew3b0.txt'
Se poi elencare i file nella directory, si noti che il vecchio file '' di output / C-7Hteo_D9vJXQ3UfzxbwnXaijM.txt '' è andata:
>>> Sistema ("Uscita ls /")
QIDaFD7KLKQh0l5O6b8exdew3b0.txt
Ys23Ag_5IOWqZCw9QGaVDdHwH00.txt
Se togliamo uno dei file creati, esso venga nuovamente:
>>> Sistema ("Uscita rm / Ys23Ag_5IOWqZCw9QGaVDdHwH00.txt")
>>> Sistema ("hashedassets mappe / ingresso map.json / *. Ingresso txt / * / *. Uscita txt /")
cp 'input / subdir / bar.txt' 'uscita / Ys23Ag_5IOWqZCw9QGaVDdHwH00.txt'
>>> Sistema ("Uscita ls /")
QIDaFD7KLKQh0l5O6b8exdew3b0.txt
Ys23Ag_5IOWqZCw9QGaVDdHwH00.txt
Se un file che sta per essere rimosso perché il contenuto originale cambiato, non viene ricreata:
>>> Sistema ("Uscita rm / QIDaFD7KLKQh0l5O6b8exdew3b0.txt")
>>> Con open ("input / pippo.txt", "w") in formato:
... File.write ("foofoofoo")
>>> Sistema ("hashedassets mappe / ingresso map.json / *. Ingresso txt / * / *. Uscita txt /")
'input / foo.txt' cp 'uscita / NdbmnXyjdY2paFzlDw9aJzCKH9w.txt'
Gestione degli errori
Tuttavia, se corriamo questo senza argomenti, non riesce:
>>> Sistema ("hashedassets", esterno = True)
Uso: hashedassets [opzioni] FILEMAPPA SOURCE [...] DEST

hashedassets: Errore: È necessario specificare almeno FILEMAPPA SOURCE e DEST

Requisiti

  • Python

Programmi simili

Cxplorer
Cxplorer

3 Jun 15

poweriso
poweriso

12 May 15

Cruiser
Cruiser

3 Jun 15

QuiXplorer
QuiXplorer

2 Jun 15

Commenti a hashedassets

I commenti non trovato
Aggiungi commento
Accendere le immagini!