From 6dec27b3d592e34d3cd145ec2cb880bf9a18cc4d Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 28 May 2013 15:47:25 +0400 Subject: [PATCH] some refactoring... Signed-off-by: Alex A. Naanou --- buildcache.py | 22 ++++++++++++++++++---- exportdirs.py | 6 ++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/buildcache.py b/buildcache.py index cd54f006..a02d4770 100755 --- a/buildcache.py +++ b/buildcache.py @@ -1,7 +1,7 @@ #======================================================================= __version__ = '''0.0.01''' -__sub_version__ = '''20130525140732''' +__sub_version__ = '''20130528154633''' __copyright__ = '''(c) Alex A. Naanou 2011''' @@ -13,6 +13,7 @@ import json import sha import urllib2 import time +from optparse import OptionParser, OptionGroup from pli.logictypes import OR @@ -396,8 +397,13 @@ def build_cache(path, config=CONFIG, gid_generator=hash_gid, #----------------------------------------------------------------------- -if __name__ == '__main__': - from optparse import OptionParser, OptionGroup +# Runtime... +#--------------------------------------------------handle_commandline--- +def handle_commandline(): + ''' + Parse commandline args and act accordingly... + ''' + res = None parser = OptionParser( usage='Usage: %prog [options] ROOT', @@ -545,7 +551,7 @@ if __name__ == '__main__': report = make_inline_report_progress(progress_state) # do the run... - build_cache(IN_PATH, + res = build_cache(IN_PATH, config, hash_gid, report, @@ -558,6 +564,14 @@ if __name__ == '__main__': print print 'Time: %.1fm' % ((progress_state['done at'] - progress_state['started at'])/60) + return res + + + +#----------------------------------------------------------------------- +if __name__ == '__main__': + + handle_commandline() diff --git a/exportdirs.py b/exportdirs.py index 5f4451f2..915d05eb 100755 --- a/exportdirs.py +++ b/exportdirs.py @@ -1,7 +1,7 @@ #======================================================================= __version__ = '''0.0.01''' -__sub_version__ = '''20130528153701''' +__sub_version__ = '''20130528154208''' __copyright__ = '''(c) Alex A. Naanou 2011''' @@ -25,7 +25,7 @@ from pprint import pprint #----------------------------------------------------------------------- #----------------------------------------------------------build_dirs--- -##!!! make this relative-path compatible... +##!!! make this figure out the path by itself... def build_dirs(data, path, rewrite=None): ''' rewrite can be: @@ -39,8 +39,6 @@ def build_dirs(data, path, rewrite=None): # gen3 if version == '2.0': - ##!!! get base path... - ##!!! img = data['image_file'] # absolute path... if img.startswith('file:///'):