Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

This is why Python is God

Name: Anonymous 2011-07-03 23:41

#!/usr/bin/env python

import hashlib
import os
import sys


def visit(files_by_size, dirname, names):
  for name in names:
    path = os.path.join(dirname, name)
    if os.path.isfile(path):
      size = os.path.getsize(path)
      if size in files_by_size:
        files_by_size[size].append(path)
      else:
        files_by_size[size] = [path]


if __name__ == '__main__':
  for dirname in sys.argv[1:]:
    files_by_size = {}
    files_by_hash = {}
    os.path.walk(dirname, visit, files_by_size)
    for size, paths in files_by_size.items():
      if len(paths) > 1:
        for path in paths:
          with open(path) as f:
            hash = hashlib.md5(f.read()).hexdigest()
            f.close()
          if hash in files_by_hash:
            files_by_hash[hash].append(path)
          else:
            files_by_hash[hash] = [path]
    for hash, paths in files_by_hash.items():
      if len(paths) > 1:
        for path in paths:
          print '%s  %s' % (hash, path)

Name: Anonymous 2011-07-05 15:58

>>40
okay now I'm mad. FUCK OFF AND DIE YOU SHIT EATING AUTISTIC LITHPER FAGSTORM. TAKE YOUR USELESS UNREADABLE PIECE OF SHIT LANGUAGE AND SHOVE IT UP YOUR GIGANTIC ASSHOLE

Name: Anonymous 2011-07-05 16:15

>>41
Less of this

Name: >>41 2011-07-05 16:15

>>42
.

Name: Anonymous 2011-07-05 16:32

>>42
nigger fagstorm

Name: Anonymous 2011-07-05 16:53

>>41
if u think lisp its shit y u mad tho lol u such a fagface gb2ur shitty language

Name: Anonymous 2011-07-05 17:26

>>1
this is why i'm an autist atheist

Name: Anonymous 2011-07-05 17:38

>>45
lisp is fucking shit and you are a cretin for thinking otherwise

Name: Anonymous 2011-07-05 18:14

>>47
u buttmad fiocfag

Name: Anonymous 2011-07-05 18:23

>>48
LITHPY NIGGERLOVRE

Name: Anonymous 2011-07-05 18:26

>>48
fiocfag here. I'm in good company.

http://en.wikipedia.org/wiki/Hal_Abelson

Name: Anonymous 2011-07-05 18:40

>>50
fuck you phython faggot

Name: Anonymous 2011-07-06 11:32

>>51
YOU ARE REALLY MAD NIGGER

Name: Anonymous 2011-07-06 13:29

six levels of indentation.

that is all.

Name: Anonymous 2011-07-06 13:35

>>53
jelly

Name: Anonymous 2011-07-06 14:33

>>53
So?

Name: Anonymous 2011-07-06 19:57

did somebody post a perl one-liner yet?

Name: Anonymous 2011-07-06 20:18

>>56

Someone posted a bash one-liner.

Name: Anonymous 2011-07-07 15:40

I hate to be the first to say it:
But isn't calculating a checksum of every file for this task... well inefficient?

A incremental check only loading the first blocks and comparing the first word of the files would be quite faster.

Name: Anonymous 2011-07-07 16:40

>>58
                               ­I shit in your face.                               ­
                         ­

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List