Skip to content

Commit

Permalink
add file size diff
Browse files Browse the repository at this point in the history
  • Loading branch information
cosyman committed Jun 23, 2015
1 parent 2a6599a commit 0c8583c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ __pycache__/
# C extensions
*.so

# IDE config
.idea/

# Distribution / packaging
.Python
env/
Expand Down
2 changes: 2 additions & 0 deletions file/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding:utf8 -*-
__author__ = 'ltyao'
15 changes: 15 additions & 0 deletions file/size_diff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- coding:utf8 -*-
__author__ = 'ltyao'
import os
from os.path import join, getsize


def cmp_size(left_dir, right_dir):
for root, dirs, files in os.walk(left_dir):
for file_name in files:
left = getsize(join(root, file_name))
right = getsize(join(root.replace(left_dir, right_dir), file_name))
if cmp(left, right) != 0:
print root, file_name, left - right


19 changes: 19 additions & 0 deletions file/size_diff_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
__author__ = 'ltyao'

import unittest
from size_diff import cmp_size


class SizeTestCase(unittest.TestCase):
def setUp(self):
self.left_dir = "D:\Users\ltyao\PycharmProjects\untitled5\NET_1367635\ws.mobilesecure.payment.soa2\payment"
self.right_dir = "D:\Users\ltyao\PycharmProjects\untitled5\NET_1368884\ws.mobilesecure.payment.soa2\payment"

def test_echo(self):
cmp_size(self.left_dir, self.right_dir)
print("--------------------")
cmp_size(self.right_dir, self.left_dir)


if __name__ == '__main__':
unittest.main()

0 comments on commit 0c8583c

Please sign in to comment.