Commit db842e43a04fb3473775158377effc3cf650fff5
1 parent
b30cbbff
oletimes: added main entry point for setup.py - issue #69
Showing
2 changed files
with
37 additions
and
27 deletions
oletools/oletimes.py
| ... | ... | @@ -47,6 +47,7 @@ http://www.decalage.info/python/oletools |
| 47 | 47 | # - improved usage display |
| 48 | 48 | # 2014-11-30 v0.03 PL: - improved output with prettytable |
| 49 | 49 | # 2016-07-20 v0.50 SL: - added Python 3 support |
| 50 | +# 2016-09-05 PL: - added main entry point for setup.py | |
| 50 | 51 | |
| 51 | 52 | __version__ = '0.50' |
| 52 | 53 | |
| ... | ... | @@ -64,37 +65,44 @@ import thirdparty.olefile as olefile |
| 64 | 65 | from thirdparty.prettytable import prettytable |
| 65 | 66 | |
| 66 | 67 | |
| 67 | -#=== MAIN ================================================================= | |
| 68 | +# === MAIN =================================================================== | |
| 68 | 69 | |
| 69 | -try: | |
| 70 | - ole = olefile.OleFileIO(sys.argv[1]) | |
| 71 | -except IndexError: | |
| 72 | - sys.exit(__doc__) | |
| 70 | +def main(): | |
| 71 | + # print banner with version | |
| 72 | + print('oletimes %s - http://decalage.info/python/oletools' % __version__) | |
| 73 | 73 | |
| 74 | -def dt2str (dt): | |
| 75 | - """ | |
| 76 | - Convert a datetime object to a string for display, without microseconds | |
| 74 | + try: | |
| 75 | + ole = olefile.OleFileIO(sys.argv[1]) | |
| 76 | + except IndexError: | |
| 77 | + sys.exit(__doc__) | |
| 77 | 78 | |
| 78 | - :param dt: datetime.datetime object, or None | |
| 79 | - :return: str, or None | |
| 80 | - """ | |
| 81 | - if dt is None: | |
| 82 | - return None | |
| 83 | - dt = dt.replace(microsecond = 0) | |
| 84 | - return str(dt) | |
| 79 | + def dt2str (dt): | |
| 80 | + """ | |
| 81 | + Convert a datetime object to a string for display, without microseconds | |
| 85 | 82 | |
| 86 | -t = prettytable.PrettyTable(['Stream/Storage name', 'Modification Time', 'Creation Time']) | |
| 87 | -t.align = 'l' | |
| 88 | -t.max_width = 26 | |
| 89 | -#t.border = False | |
| 83 | + :param dt: datetime.datetime object, or None | |
| 84 | + :return: str, or None | |
| 85 | + """ | |
| 86 | + if dt is None: | |
| 87 | + return None | |
| 88 | + dt = dt.replace(microsecond = 0) | |
| 89 | + return str(dt) | |
| 90 | 90 | |
| 91 | -#print'- Root mtime=%s ctime=%s' % (ole.root.getmtime(), ole.root.getctime()) | |
| 92 | -t.add_row(('Root', dt2str(ole.root.getmtime()), dt2str(ole.root.getctime()))) | |
| 91 | + t = prettytable.PrettyTable(['Stream/Storage name', 'Modification Time', 'Creation Time']) | |
| 92 | + t.align = 'l' | |
| 93 | + t.max_width = 26 | |
| 94 | + #t.border = False | |
| 93 | 95 | |
| 94 | -for obj in ole.listdir(streams=True, storages=True): | |
| 95 | - #print '- %s: mtime=%s ctime=%s' % (repr('/'.join(obj)), ole.getmtime(obj), ole.getctime(obj)) | |
| 96 | - t.add_row((repr('/'.join(obj)), dt2str(ole.getmtime(obj)), dt2str(ole.getctime(obj)))) | |
| 96 | + #print'- Root mtime=%s ctime=%s' % (ole.root.getmtime(), ole.root.getctime()) | |
| 97 | + t.add_row(('Root', dt2str(ole.root.getmtime()), dt2str(ole.root.getctime()))) | |
| 97 | 98 | |
| 98 | -print(t) | |
| 99 | + for obj in ole.listdir(streams=True, storages=True): | |
| 100 | + #print '- %s: mtime=%s ctime=%s' % (repr('/'.join(obj)), ole.getmtime(obj), ole.getctime(obj)) | |
| 101 | + t.add_row((repr('/'.join(obj)), dt2str(ole.getmtime(obj)), dt2str(ole.getctime(obj)))) | |
| 99 | 102 | |
| 100 | -ole.close() | |
| 103 | + print(t) | |
| 104 | + | |
| 105 | + ole.close() | |
| 106 | + | |
| 107 | +if __name__ == '__main__': | |
| 108 | + main() | ... | ... |
setup.py
| ... | ... | @@ -271,7 +271,9 @@ entry_points = { |
| 271 | 271 | 'oleid=oletools.oleid:main', |
| 272 | 272 | 'oledir=oletools.oledir:main', |
| 273 | 273 | 'olemap=oletools.olemap:main', |
| 274 | - 'pyxswf=oletools.pyxswf:main' | |
| 274 | + 'oletimes=oletools.oletimes:main', | |
| 275 | + 'pyxswf=oletools.pyxswf:main', | |
| 276 | + 'rtfobj=oletools.rtfobj:main' | |
| 275 | 277 | ], |
| 276 | 278 | } |
| 277 | 279 | ... | ... |