This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with codecs.open(filename, "rb", "utf-8") as file: | |
for ch in iter(lambda: file.read(1), ""): | |
print(ch) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
out_name, f_ext = os.path.splitext(walker_parms['out_fn']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if not len(sys.argv) > 1: | |
# There are no command-line args |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if 'win' in sys.platform: | |
default_app_dir_for_scan = 'c:\\' | |
else: | |
default_app_dir_for_scan = '~' # check for linux |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
logging.basicConfig(filename='walker.log', | |
level=logging.DEBUG, | |
format='%(asctime)s - %(levelname)s - %(lineno)d - %(message)s') | |
logging.debug('#' * 50) | |
logging.debug('---- --- start processing params ---- ---') | |
logging.debug('sys.platform is %s' % sys.platform) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_parms_from_conf_file(conf_file_name, default_parms): | |
config = configparser.ConfigParser() | |
try: | |
config.read(conf_file_name) | |
except Exception as e: | |
print("Error reading {} file".format(conf_file_name)) | |
logging.error("Error reading %s file" % conf_file_name) | |
raise e |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def load_custom_directories_list_from_file(cdl_filename): | |
if os.path.isfile(cdl_filename): | |
try: | |
with codecs.open(cdl_filename, 'r', 'utf-8') as f: | |
cdl_file_content = f.readlines() | |
# remove special chars like `\n` at the end of each line | |
cdl_file_content = [x.strip() for x in cdl_file_content] | |
return cdl_file_content | |
except Exception as e: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def show_wait(text, i): | |
if (i % 4) == 0: | |
print(text + '%s' % ("/"), end='\r') | |
elif (i % 4) == 1: | |
print(text + '%s' % ("-"), end='\r') | |
elif (i % 4) == 2: | |
print(text + '%s' % ("\\"), end='\r') | |
elif (i % 4) == 3: | |
print(text + '%s' % ("|"), end='\r') | |
elif i == -1: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_file_list_in_dir(dir_name, ext_list): | |
result_list = [] | |
tree = os.walk(dir_name) | |
i = 0 | |
logging.debug('get_file_list_in_dir(). dir_name is %s' % (dir_name)) | |
for d, dirs, files in tree: | |
for file in files: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open('workfile', 'w') as f: | |
f.write("Override existing file if exists or create new") | |
with open('workfile', 'a') as f: | |
f.write("append to existsing file if exists or create new") |
NewerOlder